[Lldb-commits] [lldb] r374583 - make ConstString allocate memory in non-tiny chunks

Lubos Lunak via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 11 12:34:39 PDT 2019


Author: llunak
Date: Fri Oct 11 12:34:39 2019
New Revision: 374583

URL: http://llvm.org/viewvc/llvm-project?rev=374583&view=rev
Log:
make ConstString allocate memory in non-tiny chunks

BumpPtrAllocator allocates in 4KiB chunks, which with any larger
project is going to result in a large number of allocations.
Increasing allocation size this way can save 10%-20% of symbol
load time for a huge C++ project with correctly built debuginfo.

Differential Revision: https://reviews.llvm.org/D68549

Modified:
    lldb/trunk/source/Utility/ConstString.cpp

Modified: lldb/trunk/source/Utility/ConstString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ConstString.cpp?rev=374583&r1=374582&r2=374583&view=diff
==============================================================================
--- lldb/trunk/source/Utility/ConstString.cpp (original)
+++ lldb/trunk/source/Utility/ConstString.cpp Fri Oct 11 12:34:39 2019
@@ -31,7 +31,10 @@ using namespace lldb_private;
 class Pool {
 public:
   typedef const char *StringPoolValueType;
-  typedef llvm::StringMap<StringPoolValueType, llvm::BumpPtrAllocator>
+  // BumpPtrAllocator allocates in 4KiB chunks, any larger C++ project is going
+  // to have megabytes of symbols, so allocate in larger chunks.
+  typedef llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 1048576> Allocator;
+  typedef llvm::StringMap<StringPoolValueType, Allocator>
       StringPool;
   typedef llvm::StringMapEntry<StringPoolValueType> StringPoolEntryType;
 
@@ -152,7 +155,9 @@ protected:
 
   struct PoolEntry {
     mutable llvm::sys::SmartRWMutex<false> m_mutex;
-    StringPool m_string_map;
+    // StringMap by default starts with 16 buckets, any larger project is
+    // going to have many symbols, so start with a larger value.
+    StringPool m_string_map = StringPool( 65536 );
   };
 
   std::array<PoolEntry, 256> m_string_pools;




More information about the lldb-commits mailing list