SmallVector and SmallPtrSet allocations not power-of-two aligned

Jean-Luc Duprat jduprat at apple.com
Wed Mar 27 14:42:02 PDT 2013


While running dtrace on a large compile, focusing on memory usage, I found several strange allocations on x64.
Here is the trimmed output of my dtrace run---these read: allocation size\t number of such allocations

[snip: trimmed, leaving only allocation that seemed odd]
            32776              156
            16392              446
             8200              604
             4104              605
             2056              614
             1032             1212

Note that these allocations are 1032 bytes (1024+8), 2056 bytes (2048+8), 4104 bytes (4096+8), etc.

These were tracked down to SmallVector and SmallPtrSet, and the way they grow when no longer "small".
For SmallVector the fix is pretty minimal, just using better logic to compute the size of the next  allocation.  For SmallPtrSet the fix involved getting the allocator to track the end of the set, growing the size of the allocator itself rather than growing the set.

These changes moved all the allocations identified above to proper power-of-two allocations.  These changes have no impact on performance, but will help pool memory allocations together if needed.

Please provide feedback on the attached change.
Thank you,

JL



-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_allocs.patch
Type: application/octet-stream
Size: 8589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130327/062e7b00/attachment.obj>
-------------- next part --------------




More information about the llvm-commits mailing list