aboutsummaryrefslogtreecommitdiff
path: root/zencore/iobuffer.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-04-28 22:17:20 +0200
committerGitHub <[email protected]>2022-04-28 22:17:20 +0200
commit8b7d5557dfacd0527d30bccaf4b9dbeb060be674 (patch)
treee8e733d73f4f251a8bf3daa043e8e299ed44ed00 /zencore/iobuffer.cpp
parentMerge pull request #81 from EpicGames/de/use-bulk-fetch-from-upstream-on-getc... (diff)
parentReduce risk of reallocating backing std::vector in CbWriter::AddBinary (diff)
downloadzen-8b7d5557dfacd0527d30bccaf4b9dbeb060be674.tar.xz
zen-8b7d5557dfacd0527d30bccaf4b9dbeb060be674.zip
Merge pull request #83 from EpicGames/de/minor-optimizationsv1.0.0.7
Minor optimizations to reduce overhead during high load
Diffstat (limited to 'zencore/iobuffer.cpp')
-rw-r--r--zencore/iobuffer.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp
index 8a3ab8427..c069aa0f1 100644
--- a/zencore/iobuffer.cpp
+++ b/zencore/iobuffer.cpp
@@ -226,7 +226,15 @@ IoBufferExtendedCore::~IoBufferExtendedCore()
m_DataPtr = nullptr;
}
-static RwLock g_MappingLock;
+static RwLock g_MappingLock[0x40];
+
+static RwLock&
+MappingLockForInstance(const IoBufferExtendedCore* instance)
+{
+ intptr_t base = (intptr_t)instance;
+ size_t lock_index = ((base >> 8) ^ (base >> 16)) & 0x3f;
+ return g_MappingLock[lock_index];
+}
void
IoBufferExtendedCore::Materialize() const
@@ -237,7 +245,7 @@ IoBufferExtendedCore::Materialize() const
if (m_Flags.load(std::memory_order_acquire) & kIsMaterialized)
return;
- RwLock::ExclusiveLockScope _(g_MappingLock);
+ RwLock::ExclusiveLockScope _(MappingLockForInstance(this));
// Someone could have gotten here first
// We can use memory_order_relaxed on this load because the mutex has already provided the fence