[compiler-rt] [scudo] Reduce thread contention in secondary cache releases. (PR #102984)
Joshua Baehring via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 09:05:11 PDT 2024
================
@@ -351,9 +351,13 @@ class MapAllocatorCache {
for (MemMapT &EvictMemMap : EvictionMemMaps)
unmapCallBack(EvictMemMap);
- if (Interval >= 0) {
+ // If a thread already holds the mutex, the current thread can
----------------
JoshuaMBa wrote:
I ran some checks internally, and it seems that even on processes with the most threads (~200), there is only about 1 or 2 contended acquisitions of the lock per 1000 calls to store, so it's probably not justified to add this if we're concerned about the second case.
Just to clarify, however, I wasn't saying we should replace `Mutex` but rather add another `HybridMutex` if we wanted to avoid the second case. It would look something like
```
if (Interval >= 0 && ReleaseMutex.tryLock()) {
CacheMutex.lock()
releaseOlderThan(Time);
CacheMutex.unlock();
ReleaseMutex.unlock();
}
```
where `CacheMutex` is the original `Mutex` in the current code. However, given that there doesn't seem to be much of a need for reducing contention here, I think we can close this pull request for now. Let me know what you think.
https://github.com/llvm/llvm-project/pull/102984
More information about the llvm-commits
mailing list