diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-28 15:32:55 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-28 15:32:55 +0200 |
| commit | db2bee546354a03ca9a94a647161b041b3033491 (patch) | |
| tree | e8e733d73f4f251a8bf3daa043e8e299ed44ed00 /zencore/iobuffer.cpp | |
| parent | Merge pull request #81 from EpicGames/de/use-bulk-fetch-from-upstream-on-getc... (diff) | |
| download | zen-db2bee546354a03ca9a94a647161b041b3033491.tar.xz zen-db2bee546354a03ca9a94a647161b041b3033491.zip | |
Reduce risk of reallocating backing std::vector in CbWriter::AddBinary
Shard up g_MappingLock in IoBufferExtendedCore::Materialize() to reduce contention during high load
Don't queue upstream cache records if we don't have any upstreams
Diffstat (limited to 'zencore/iobuffer.cpp')
| -rw-r--r-- | zencore/iobuffer.cpp | 12 |
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 |