summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2020-06-16 13:05:55 -0700
committerChristopher Ferris <cferris@google.com>2020-06-16 13:15:15 -0700
commit22b24a2ba359143ea40ceec99a81abaad551f3f9 (patch)
tree0d248d610d562451a6a13b8817574863afe54d55
parent4279ca289b01749102ce3efb7015ded272a4e470 (diff)
downloadscudo-22b24a2ba359143ea40ceec99a81abaad551f3f9.tar.gz
Release smaller classes only when there are lots of free chunks.
Bug: 156713286 Test: Ran scudo unit tests. Test: Ran full performance/RSS tests. Test: Ran cts-tradefed run cts --include-filter "armeabi-v7a CtsLibcoreOjTestCases" Change-Id: I757ca67ad633b4641511fdd8d25d759f23640624
-rw-r--r--standalone/local_cache.h1
-rw-r--r--standalone/primary32.h8
2 files changed, 9 insertions, 0 deletions
diff --git a/standalone/local_cache.h b/standalone/local_cache.h
index a6425fc6d1e..089aeb93962 100644
--- a/standalone/local_cache.h
+++ b/standalone/local_cache.h
@@ -159,6 +159,7 @@ private:
DCHECK_GT(B->getCount(), 0);
C->Count = B->getCount();
B->copyToArray(C->Chunks);
+ B->clear();
destroyBatch(ClassId, B);
return true;
}
diff --git a/standalone/primary32.h b/standalone/primary32.h
index 9dac4989991..262793158b0 100644
--- a/standalone/primary32.h
+++ b/standalone/primary32.h
@@ -446,6 +446,14 @@ private:
}
}
+ if (BlockSize < PageSize / 16) {
+ if (BytesPushed < (Sci->AllocatedUser / 16U))
+ return 0;
+ if (BytesInFreeList / (Sci->AllocatedUser / 100U) <
+ (100U - getMostSignificantSetBitIndex(BlockSize) * 2))
+ return 0;
+ }
+
// TODO(kostyak): currently not ideal as we loop over all regions and
// iterate multiple times over the same freelist if a ClassId spans multiple
// regions. But it will have to do for now.