sanitizer_common: optimize memory drain
authorDmitry Vyukov <dvyukov@google.com>
Sun, 11 Jul 2021 13:12:24 +0000 (15:12 +0200)
committerDmitry Vyukov <dvyukov@google.com>
Tue, 13 Jul 2021 08:02:23 +0000 (10:02 +0200)
commitd89d3dfae17d7795dc1ef013db66272020de1959
tree21a34af5681ff10ecb3f2ec95c10b01b8a671c1f
parent954a15d6398edbb839d4b842534b50e85d4aa8cd
sanitizer_common: optimize memory drain

Currently we allocate MemoryMapper per size class.
MemoryMapper mmap's and munmap's internal buffer.
This results in 50 mmap/munmap calls under the global
allocator mutex. Reuse MemoryMapper and the buffer
for all size classes. This radically reduces number of
mmap/munmap calls. Smaller size classes tend to have
more objects allocated, so it's highly likely that
the buffer allocated for the first size class will
be enough for all subsequent size classes.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D105778
compiler-rt/lib/sanitizer_common/sanitizer_allocator_local_cache.h
compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp