[compiler-rt] [scudo] Added LRU eviction policy to secondary cache. (PR #99409)
Joshua Baehring via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 16:17:52 PDT 2024
================
@@ -269,30 +299,27 @@ template <typename Config> class MapAllocatorCache {
OldestTime = Entry.Time;
Entry = PrevEntry;
}
- if (EntriesCount >= MaxCount) {
- if (IsFullEvents++ == 4U)
- EmptyCache = true;
- } else {
- for (u32 I = 0; I < MaxCount; I++) {
- if (Entries[I].isValid())
- continue;
- if (I != 0)
- Entries[I] = Entries[0];
- Entries[0] = Entry;
- EntriesCount++;
- if (OldestTime == 0)
- OldestTime = Entry.Time;
- EntryCached = true;
- break;
- }
+
+ // All excess entries are evicted from the cache
+ while (EntriesCount >= MaxCount) {
+ // Save MemMaps of evicted entries to perform unmap outside of lock
+ EvictionMemMaps.push_back(Entries[LRUTail].MemMap);
+ remove(LRUTail);
----------------
JoshuaMBa wrote:
Just to clarify, you want `needToEvict` to decrement the `EntriesCount` variable instead? And if we do that, should something similar be done for `insert`?
https://github.com/llvm/llvm-project/pull/99409
More information about the llvm-commits
mailing list