[PATCH] D82031: [scudo][standalone] Release smaller blocks less often
Kostya Kortchinsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 18 09:46:11 PDT 2020
cryptoad updated this revision to Diff 271751.
cryptoad added a comment.
Only do the `BytesPushed` check is not doing a forced release.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82031/new/
https://reviews.llvm.org/D82031
Files:
compiler-rt/lib/scudo/standalone/local_cache.h
compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/primary64.h
Index: compiler-rt/lib/scudo/standalone/primary64.h
===================================================================
--- compiler-rt/lib/scudo/standalone/primary64.h
+++ compiler-rt/lib/scudo/standalone/primary64.h
@@ -213,9 +213,7 @@
return reinterpret_cast<const char *>(RegionInfoArray);
}
- static uptr getRegionInfoArraySize() {
- return sizeof(RegionInfoArray);
- }
+ static uptr getRegionInfoArraySize() { return sizeof(RegionInfoArray); }
static BlockInfo findNearestBlock(const char *RegionInfoData, uptr Ptr) {
const RegionInfo *RegionInfoArray =
@@ -458,6 +456,18 @@
if (BytesPushed < PageSize)
return 0; // Nothing new to release.
+ // Releasing smaller blocks is expensive, so we want to make sure that a
+ // significant amount of bytes are free, and that there has been a good
+ // amount of batches pushed to the freelist before attempting to release.
+ if (BlockSize < PageSize / 16U) {
+ if (!Force && BytesPushed < Region->AllocatedUser / 16U)
+ return 0;
+ // We want 8x% to 9x% free bytes (the larger the bock, the lower the %).
+ if ((BytesInFreeList * 100U) / Region->AllocatedUser <
+ (100U - 1U - BlockSize / 16U))
+ return 0;
+ }
+
if (!Force) {
const s32 IntervalMs = getReleaseToOsIntervalMs();
if (IntervalMs < 0)
Index: compiler-rt/lib/scudo/standalone/primary32.h
===================================================================
--- compiler-rt/lib/scudo/standalone/primary32.h
+++ compiler-rt/lib/scudo/standalone/primary32.h
@@ -444,6 +444,18 @@
if (BytesPushed < PageSize)
return 0; // Nothing new to release.
+ // Releasing smaller blocks is expensive, so we want to make sure that a
+ // significant amount of bytes are free, and that there has been a good
+ // amount of batches pushed to the freelist before attempting to release.
+ if (BlockSize < PageSize / 16U) {
+ if (!Force && BytesPushed < Sci->AllocatedUser / 16U)
+ return 0;
+ // We want 8x% to 9x% free bytes (the larger the bock, the lower the %).
+ if ((BytesInFreeList * 100U) / Sci->AllocatedUser <
+ (100U - 1U - BlockSize / 16U))
+ return 0;
+ }
+
if (!Force) {
const s32 IntervalMs = getReleaseToOsIntervalMs();
if (IntervalMs < 0)
Index: compiler-rt/lib/scudo/standalone/local_cache.h
===================================================================
--- compiler-rt/lib/scudo/standalone/local_cache.h
+++ compiler-rt/lib/scudo/standalone/local_cache.h
@@ -159,6 +159,7 @@
DCHECK_GT(B->getCount(), 0);
C->Count = B->getCount();
B->copyToArray(C->Chunks);
+ B->clear();
destroyBatch(ClassId, B);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82031.271751.patch
Type: text/x-patch
Size: 2754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200618/016ba6ca/attachment.bin>
More information about the llvm-commits
mailing list