summaryrefslogtreecommitdiff
path: root/include/llvm/Support/Allocator.h
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-03-28 08:53:25 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-03-28 08:53:25 +0000
commit415a008ad210bd20caa251fab68c4a5a21477b5d (patch)
treee47151f070312f24efdd4ca4a68819b1ae7440f6 /include/llvm/Support/Allocator.h
parentec90ab499d42cdb24bcb9c4a425c2d3789e077bc (diff)
downloadllvm-415a008ad210bd20caa251fab68c4a5a21477b5d.tar.gz
llvm-415a008ad210bd20caa251fab68c4a5a21477b5d.tar.bz2
llvm-415a008ad210bd20caa251fab68c4a5a21477b5d.tar.xz
[Allocator Cleanup] Make the growth of the "slab" size of the
BumpPtrAllocator significantly less strange by making it a simple function of the number of slabs allocated rather than by making it a recurrance. I *think* the previous behavior was essentially that the size of the slabs would be doubled after the first 128 were allocated, and then doubled again each time 64 more were allocated, but only if every allocation packed perfectly into the slab size. If not, the wasted space wouldn't be counted toward increasing the size, but allocations over the size threshold *would*. And since the allocations over the size threshold might be much larger than the slab size, this could have somewhat surprising consequences where we rapidly grow the slab size. This currently requires adding state to the allocator to track the number of slabs currently allocated, but that isn't too bad. I'm planning further changes to the allocator that will make this state fall out even more naturally. It still doesn't fully decouple the growth rate from the allocations which are over the size threshold. That fix is coming later. This specific fix will allow making the entire thing into a more stateless device and lifting the parameters into template parameters rather than runtime parameters. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204993 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/Allocator.h')
-rw-r--r--include/llvm/Support/Allocator.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h
index 30fd7e9071..a3ed5994af 100644
--- a/include/llvm/Support/Allocator.h
+++ b/include/llvm/Support/Allocator.h
@@ -132,6 +132,12 @@ class BumpPtrAllocator {
/// Used so that we can compute how much space was wasted.
size_t BytesAllocated;
+ /// \brief How many slabs we've allocated.
+ ///
+ /// Used to scale the size of each slab and reduce the number of allocations
+ /// for extremely heavy memory use scenarios.
+ size_t NumSlabs;
+
/// \brief Aligns \c Ptr to \c Alignment bytes, rounding up.
///
/// Alignment should be a power of two. This method rounds up, so
@@ -179,7 +185,7 @@ public:
void Deallocate(const void * /*Ptr*/) {}
- unsigned GetNumSlabs() const;
+ size_t GetNumSlabs() const { return NumSlabs; }
void PrintStats() const;