[compiler-rt] [scudo] Update secondary cache released pages bound. (PR #106466)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 16:05:41 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Joshua Baehring (JoshuaMBa)

<details>
<summary>Changes</summary>

`MaxReleasedCachePages` has been set to 4. Initially, in #<!-- -->105009 , we set `MaxReleasedCachePages` to 0 so that partial chunk heuristic could be introduced incrementally as we observed its impact on retrieval order and more generally, performance.

---
Full diff: https://github.com/llvm/llvm-project/pull/106466.diff


1 Files Affected:

- (modified) compiler-rt/lib/scudo/standalone/secondary.h (+5-9) 


``````````diff
diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h
index fba21c3cb6a09d..5d1be0a9fd5cea 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -79,8 +79,7 @@ struct CachedBlock {
   //        it suggests that beyond 4 pages, the release execution time is
   //        longer than the map execution time. In this way, the default
   //        is dependent on the platform.
-  //    TODO: set MaxReleasedCachePages back to 4U
-  static constexpr uptr MaxReleasedCachePages = 0U;
+  static constexpr uptr MaxReleasedCachePages = 4U;
 
   uptr CommitBase = 0;
   uptr CommitSize = 0;
@@ -389,17 +388,14 @@ class MapAllocatorCache {
         const uptr HeaderPos = AllocPos - HeadersSize;
         const uptr MaxAllowedFragmentedBytes =
             MaxAllowedFragmentedPages * PageSize;
-        if (HeaderPos > CommitBase + CommitSize)
+        if (HeaderPos > CommitBase + CommitSize || HeaderPos < CommitBase)
           continue;
-        // TODO: Remove AllocPos > CommitBase + MaxAllowedFragmentedBytes
-        // and replace with Diff > MaxAllowedFragmentedBytes
-        if (HeaderPos < CommitBase ||
-            AllocPos > CommitBase + MaxAllowedFragmentedBytes) {
-          continue;
-        }
 
         const uptr Diff = roundDown(HeaderPos, PageSize) - CommitBase;
 
+        if (Diff > MaxAllowedFragmentedBytes)
+          continue;
+
         // Keep track of the smallest cached block
         // that is greater than (AllocSize + HeaderSize)
         if (Diff >= MinDiff)

``````````

</details>


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


More information about the llvm-commits mailing list