This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Construct InternalMmapVector without memory allocation.
ClosedPublic

Authored by ikudrin on Dec 11 2019, 3:14 AM.

Details

Summary

Construction of InternalMmapVector is often followed by a call to reserve(), which may result in immediate reallocation of the memory for the internal storage. This patch delays that allocation until it is really needed.

Diff Detail

Event Timeline

ikudrin created this revision.Dec 11 2019, 3:14 AM

I'd like to note that this is not a purely theoretical issue. It can be observed, for example, in Symbolizer::ModuleNameOwner on a 64-bit platform with 4K memory pages. The default constructor for storage_ allocates one memory page, which is immediately replaced by a new allocation in the call to reserve() for 1000 elements, which requires 8 * 1000 = 8000 bytes, or two pages.

This revision is now accepted and ready to land.Dec 16 2019, 10:53 AM
This revision was automatically updated to reflect the committed changes.