[llvm] r307608 - llvm-profdata: Improve memory usage by tuning SmallDenseMap size

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 18:18:28 PDT 2017


Author: dblaikie
Date: Mon Jul 10 18:18:28 2017
New Revision: 307608

URL: http://llvm.org/viewvc/llvm-project?rev=307608&view=rev
Log:
llvm-profdata: Improve memory usage by tuning SmallDenseMap size

This takes memory usage from 5.1GB to 970MB - it could go further by
using a small size of 2 instead of the default of 4, but given the
rather high cost of going over this limit by much, I figured a little
slosh would be worth the ~130MB of memory usage.

& this'll might not be such a big deal if we use a custom slab allocator
for the DenseMaps here anyway

While the vast majority (99.9%) of records use only 1 entry, the tuning
parameter to SmallDenseMap is the the number of buckets, not the number
of entries - so a small size of 1 wasn't useful, even for 1 element, it
would tip over into allocating (much, 64 slots worth) more space - none
of them ended up small.

Modified:
    llvm/trunk/include/llvm/ProfileData/InstrProfWriter.h

Modified: llvm/trunk/include/llvm/ProfileData/InstrProfWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProfWriter.h?rev=307608&r1=307607&r2=307608&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProfWriter.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProfWriter.h Mon Jul 10 18:18:28 2017
@@ -33,8 +33,7 @@ class raw_fd_ostream;
 
 class InstrProfWriter {
 public:
-  using ProfilingData =
-      SmallDenseMap<uint64_t, InstrProfRecord, 1>;
+  using ProfilingData = SmallDenseMap<uint64_t, InstrProfRecord>;
   enum ProfKind { PF_Unknown = 0, PF_FE, PF_IRLevel };
 
 private:




More information about the llvm-commits mailing list