This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Switch StackStore to 8 MiB blocks
ClosedPublic

Authored by vitalybuka on Nov 23 2021, 5:03 PM.

Details

Summary

Larger blocks are more convenient for compressions.
Blocks are allocated with MmapNoReserveOrDie to save some memory.

Also it's 15% faster on StackDepotBenchmarkSuite

Depends on D114464.

Diff Detail

Event Timeline

vitalybuka requested review of this revision.Nov 23 2021, 5:03 PM
vitalybuka created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2021, 5:03 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka edited the summary of this revision. (Show Details)Nov 23 2021, 5:13 PM

fix comment

I think this could be a thin wrapper around TwoLevelMap.

compiler-rt/lib/sanitizer_common/sanitizer_stack_store.h
57

Does this = {} do anything? It confuses me. It produces impression that it initializes something, but does it?

63

Why do we want it to be 0x100000000ull in total? If this assert fails, do I need to fix the code back, or update the 0x100000000ull number?

I think this could be a thin wrapper around TwoLevelMap.

Looking at the subsequent commits, it probably can't be TwoLevelMap.

I think this could be a thin wrapper around TwoLevelMap.

yep. I need to pack and unmap blocks, which is not supported by TwoLevelMap. If we add that into TwoLevelMap it will be more branching or syncronization of fast path of TwoLevelMap which is used is allocator.

I think this could be a thin wrapper around TwoLevelMap.

Looking at the subsequent commits, it probably can't be TwoLevelMap.

compiler-rt/lib/sanitizer_common/sanitizer_stack_store.h
57

It does zero init and let you have constexpr constructor
It would not be needed if StaticSpinMutex had one

63

Right, this assert belongs to later patch which makes using Id = u32

vitalybuka added inline comments.Nov 24 2021, 9:51 AM
compiler-rt/lib/sanitizer_common/sanitizer_stack_store.h
57

Or you saing that it useless because of BlockInfo blocks_[kBlockCount] = {}; below?
Than it's true

vitalybuka marked 2 inline comments as done.

remove assert and {}

morehouse accepted this revision.Nov 24 2021, 11:35 AM
morehouse added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
94

I think relaxed ordering also works here.

This revision is now accepted and ready to land.Nov 24 2021, 11:35 AM
vitalybuka marked an inline comment as done.

order relaxed

dvyukov added inline comments.Nov 24 2021, 10:55 PM
compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
94

Relaxed does not work here. Here is proper implementation of double-checked locking in C++:
https://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_C++11

vitalybuka marked an inline comment as done.

restore release

This revision was automatically updated to reflect the committed changes.