[PATCH] D74869: [scudo][standalone] Drain the start of a cache, not the end
Kostya Kortchinsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 13:39:21 PST 2020
cryptoad created this revision.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.
When we add a pointer to a cache, we add it at the end. By draining the
end, we were effectively putting back into the central freelist what
was just put in the local cache.
This improves performances, with no impact on memory footprint.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74869
Files:
compiler-rt/lib/scudo/standalone/local_cache.h
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
@@ -165,13 +165,14 @@
NOINLINE void drain(PerClass *C, uptr ClassId) {
const u32 Count = Min(C->MaxCount / 2, C->Count);
- const uptr FirstIndexToDrain = C->Count - Count;
- TransferBatch *B = createBatch(ClassId, C->Chunks[FirstIndexToDrain]);
+ TransferBatch *B = createBatch(ClassId, C->Chunks[0]);
if (UNLIKELY(!B))
reportOutOfMemory(
SizeClassAllocator::getSizeByClassId(SizeClassMap::BatchClassId));
- B->setFromArray(&C->Chunks[FirstIndexToDrain], Count);
+ B->setFromArray(&C->Chunks[0], Count);
C->Count -= Count;
+ for (uptr I = 0; I < C->Count; I++)
+ C->Chunks[I] = C->Chunks[I + Count];
Allocator->pushBatch(ClassId, B);
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74869.245507.patch
Type: text/x-patch
Size: 933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200219/106dc250/attachment.bin>
More information about the llvm-commits
mailing list