From e2ca7cb504a84b7a64c670455eb5e66e9cf0ecff Mon Sep 17 00:00:00 2001 From: Lubos Lunak Date: Fri, 11 Oct 2019 19:34:39 +0000 Subject: [PATCH] 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 llvm-svn: 374583 --- lldb/source/Utility/ConstString.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp index 2516ecf6a989..238fd7bdd28d 100644 --- a/lldb/source/Utility/ConstString.cpp +++ b/lldb/source/Utility/ConstString.cpp @@ -31,7 +31,10 @@ using namespace lldb_private; class Pool { public: typedef const char *StringPoolValueType; - typedef llvm::StringMap + // BumpPtrAllocator allocates in 4KiB chunks, any larger C++ project is going + // to have megabytes of symbols, so allocate in larger chunks. + typedef llvm::BumpPtrAllocatorImpl Allocator; + typedef llvm::StringMap StringPool; typedef llvm::StringMapEntry StringPoolEntryType; @@ -152,7 +155,9 @@ protected: struct PoolEntry { mutable llvm::sys::SmartRWMutex 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 m_string_pools;