r204910 - [cleanup] Stop specifying size overrides for BumpPtrAllocators.

Chandler Carruth chandlerc at gmail.com
Thu Mar 27 03:45:22 PDT 2014


Author: chandlerc
Date: Thu Mar 27 05:45:22 2014
New Revision: 204910

URL: http://llvm.org/viewvc/llvm-project?rev=204910&view=rev
Log:
[cleanup] Stop specifying size overrides for BumpPtrAllocators.

These don't seem to have any real point. Let's start with
IndexingContext. I can't come up with any conceivable reason to have
many hundereds of thousands of these alive in an address space which
would make the 4x difference in allocated (but unused) memory for the
string scratch buffer a significant memory usage problem.

The EditedSource one is somewhat more surprising. This is an 8x increase
in the memory allocated (but not used) per editted source file. However,
for this to realistically be a problem, you would need to have over half
a million editted source files in a single address space, and even that
would only really have problems on 32-bit Windows where you really only
have 2gb of virtual address space. And what's more important, the fix to
this if it is actually an issue shouldn't be to shrink the allocator's
size, it is to pass a single allocator into *many* edited source file
objects and let them share the memory.

These were the only two uses of custom sized BumpPtrAllocators
(excluding ones in the JIT using a custom allocation strategy) in all of
LLVM, Clang, LLD, LLDB, or Polly. I don't think we actually need this
complexity in the primary BumpPtrAllocator at all and am planning to
remove it.

Modified:
    cfe/trunk/include/clang/Edit/EditedSource.h
    cfe/trunk/tools/libclang/IndexingContext.h

Modified: cfe/trunk/include/clang/Edit/EditedSource.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Edit/EditedSource.h?rev=204910&r1=204909&r2=204910&view=diff
==============================================================================
--- cfe/trunk/include/clang/Edit/EditedSource.h (original)
+++ cfe/trunk/include/clang/Edit/EditedSource.h Thu Mar 27 05:45:22 2014
@@ -50,7 +50,7 @@ public:
                const bool FCommitInSystemHeader = true)
     : SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec),
       ForceCommitInSystemHeader(FCommitInSystemHeader),
-      StrAlloc(/*size=*/512) { }
+      StrAlloc() { }
 
   const SourceManager &getSourceManager() const { return SourceMgr; }
   const LangOptions &getLangOpts() const { return LangOpts; }

Modified: cfe/trunk/tools/libclang/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.h?rev=204910&r1=204909&r2=204910&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.h (original)
+++ cfe/trunk/tools/libclang/IndexingContext.h Thu Mar 27 05:45:22 2014
@@ -335,7 +335,7 @@ public:
                   unsigned indexOptions, CXTranslationUnit cxTU)
     : Ctx(0), ClientData(clientData), CB(indexCallbacks),
       IndexOptions(indexOptions), CXTU(cxTU),
-      StrScratch(/*size=*/1024), StrAdapterCount(0) { }
+      StrScratch(), StrAdapterCount(0) { }
 
   ASTContext &getASTContext() const { return *Ctx; }
 





More information about the cfe-commits mailing list