Skip to content

Conversation

JoshuaMBa
Copy link
Contributor

@JoshuaMBa JoshuaMBa commented Aug 28, 2024

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

@llvmbot
Copy link
Member

llvmbot commented Aug 28, 2024

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

Author: Joshua Baehring (JoshuaMBa)

Changes

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 --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)

`MaxReleasedCachePages` has been set to 4.
@JoshuaMBa JoshuaMBa force-pushed the update_pch_algorithm branch from 81f336a to a593986 Compare August 29, 2024 00:25
@ChiaHungDuan ChiaHungDuan merged commit 0ef7b1d into llvm:main Sep 3, 2024
7 checks passed
@JoshuaMBa JoshuaMBa deleted the update_pch_algorithm branch September 3, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants