This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Fragmentation info secondary cache
ClosedPublic

Authored by frs513 on Aug 9 2023, 10:50 AM.

Details

Summary

Added a variable that tracks the FragmentedBytes in the secondary cache.
Updates this information after successful retrieves and stores. Dumps
info in getStats().

Diff Detail

Event Timeline

frs513 created this revision.Aug 9 2023, 10:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2023, 10:50 AM
Herald added subscribers: yaneury, Enna1. · View Herald Transcript
frs513 requested review of this revision.Aug 9 2023, 10:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2023, 10:50 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
Chia-hungDuan added inline comments.Aug 9 2023, 10:58 AM
compiler-rt/lib/scudo/standalone/secondary.h
262

I think we may want to track all secondary allocations because we don't know if a returned block is cached before. Then we add the fragmented bytes at every allocation and subtract it at every deallocation

frs513 added inline comments.Aug 9 2023, 11:10 AM
compiler-rt/lib/scudo/standalone/secondary.h
262

So I should be doing these calculations in the allocate & deallocate methods instead of retrieve and store?

Chia-hungDuan added inline comments.Aug 9 2023, 12:11 PM
compiler-rt/lib/scudo/standalone/secondary.h
262

Right, so that we won't miss some of them like if the cache is full, you can't store it

frs513 updated this revision to Diff 548824.Aug 9 2023, 5:09 PM

moved FragmentedBytes calculation to allocate/deallocate methods

frs513 updated this revision to Diff 548827.Aug 9 2023, 5:11 PM

added a "\n" to stats dump for clarity

frs513 marked 2 inline comments as done.Aug 9 2023, 5:11 PM

Stats: MapAllocator: allocated 34 times (2404K), freed 34 times (2404K), remains 0 (0K) max 0M, Fragmented 18014398509481850K
.
.
.
Stats: MapAllocator: allocated 7683 times (1066772K), freed 7683 times (1066772K), remains 0 (0K) max 1M, Fragmented 4081387162245704K

.
.
.
Stats: MapAllocator: allocated 32 times (1180K), freed 32 times (1180K), remains 0 (0K) max 0M, Fragmented 15762598695796610K
.
.
.
These are the values I am getting, which do not make sense, I assume my arithmetic is leading to overflow

Chia-hungDuan added inline comments.Aug 9 2023, 5:15 PM
compiler-rt/lib/scudo/standalone/secondary.h
670

I think you also want to account the Fragmented bytes here

frs513 marked an inline comment as done.Aug 9 2023, 5:37 PM
frs513 added inline comments.
compiler-rt/lib/scudo/standalone/secondary.h
670

I added the calculation here and now I am getting 0K fragmented

frs513 updated this revision to Diff 548833.Aug 9 2023, 5:39 PM
frs513 marked an inline comment as done.

added Fragmentation calculation to another place that I had not concidered before

Chia-hungDuan accepted this revision.Aug 10 2023, 8:49 AM
This revision is now accepted and ready to land.Aug 10 2023, 8:49 AM
frs513 added inline comments.Aug 10 2023, 11:38 AM
compiler-rt/lib/scudo/standalone/secondary.h
701

I was dumping this in the CacheRetrieveStats, but now since I am doing the calculations in the MapAllocator, it is getting dumped here. I am wondering if I should also move the SuccessRate to this getStats()?

This revision was automatically updated to reflect the committed changes.