[compiler-rt] 12a22ec - [scudo] Dump MapAllocatorCache::retrieve() data
Chia-hung Duan via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 7 18:33:47 PDT 2023
Author: Fernando
Date: 2023-08-08T01:32:29Z
New Revision: 12a22ec755a71f09d308f6550bb07f4b62ed3332
URL: https://github.com/llvm/llvm-project/commit/12a22ec755a71f09d308f6550bb07f4b62ed3332
DIFF: https://github.com/llvm/llvm-project/commit/12a22ec755a71f09d308f6550bb07f4b62ed3332.diff
LOG: [scudo] Dump MapAllocatorCache::retrieve() data
Keeps track of CallsToRetrieve, how many SuccessfulRetrieves, from
cached block allocations. Dumps this data in the
MapAllocatorCache::getStats() function
Reviewed By: cferris, Chia-hungDuan
Differential Revision: https://reviews.llvm.org/D157154
Added:
Modified:
compiler-rt/lib/scudo/standalone/secondary.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h
index 4573f56f7ee6f0..06076fdd0aa553 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -155,10 +155,22 @@ template <typename Config> class MapAllocatorCache {
void getStats(ScopedString *Str) {
ScopedLock L(Mutex);
+ u32 Integral = 0;
+ u32 Fractional = 0;
+ if (CallsToRetrieve != 0) {
+ Integral = SuccessfulRetrieves * 100 / CallsToRetrieve;
+ Fractional = (((SuccessfulRetrieves * 100) % CallsToRetrieve) * 100 +
+ CallsToRetrieve / 2) /
+ CallsToRetrieve;
+ }
Str->append("Stats: MapAllocatorCache: EntriesCount: %d, "
"MaxEntriesCount: %u, MaxEntrySize: %zu\n",
EntriesCount, atomic_load_relaxed(&MaxEntriesCount),
atomic_load_relaxed(&MaxEntrySize));
+ Str->append("Stats: CacheRetrievalStats: SuccessRate: %u/%u "
+ "(%u.%02u%%)\n",
+ SuccessfulRetrieves, CallsToRetrieve,
+ Integral, Fractional);
for (CachedBlock Entry : Entries) {
if (!Entry.isValid())
continue;
@@ -272,6 +284,7 @@ template <typename Config> class MapAllocatorCache {
uptr HeaderPos = 0;
{
ScopedLock L(Mutex);
+ CallsToRetrieve++;
if (EntriesCount == 0)
return false;
for (u32 I = 0; I < MaxCount; I++) {
@@ -292,6 +305,7 @@ template <typename Config> class MapAllocatorCache {
Entry = Entries[I];
Entries[I].invalidate();
EntriesCount--;
+ SuccessfulRetrieves++;
break;
}
}
@@ -428,6 +442,8 @@ template <typename Config> class MapAllocatorCache {
u64 OldestTime GUARDED_BY(Mutex) = 0;
u32 IsFullEvents GUARDED_BY(Mutex) = 0;
atomic_s32 ReleaseToOsIntervalMs = {};
+ u32 CallsToRetrieve GUARDED_BY(Mutex) = 0;
+ u32 SuccessfulRetrieves GUARDED_BY(Mutex) = 0;
CachedBlock Entries[CacheConfig::EntriesArraySize] GUARDED_BY(Mutex) = {};
NonZeroLengthArray<CachedBlock, CacheConfig::QuarantineSize>
More information about the llvm-commits
mailing list