[compiler-rt] [scudo] Reduce thread contention in secondary cache releases. (PR #102984)

Joshua Baehring via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 20:53:53 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've updated the comment, but now that I think about it, do you think it would be worth adding a lock specifically for releases? So instead we would have something like 

```
if (Interval >= 0 && ReleaseMutex.tryLock()) {
      releaseOlderThan(Time);
      ReleaseMutex.unlock();
}
```
where `releaseOlderThan()` acquires the cache lock inside the function? 

https://github.com/llvm/llvm-project/pull/102984


More information about the llvm-commits mailing list