[llvm-commits] CVS: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp PoolAllocator.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Mar 4 22:40:01 PST 2004
Changes in directory poolalloc/runtime/FL2Allocator:
FreeListAllocator.cpp updated: 1.6 -> 1.7
PoolAllocator.h updated: 1.1 -> 1.2
---
Log message:
Instead of allocating fixed sized slabs, grow the amount allocated exponentially
this makes both extremely small and extremely large pools cheaper and speeds up
programs substantially!
---
Diffs of the changes: (+11 -4)
Index: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
diff -u poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.6 poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.7
--- poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.6 Tue Mar 2 22:00:19 2004
+++ poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Thu Mar 4 22:39:09 2004
@@ -24,7 +24,7 @@
//
//===----------------------------------------------------------------------===//
-#define PageSize (18U*1024U)
+#define PageSize (4*1024U)
#define DEBUG(X)
//#define DEBUG(X) X
@@ -46,11 +46,13 @@
// create - Create a new (empty) slab and add it to the end of the Pools list.
void PoolSlab::create(PoolTy *Pool) {
- PoolSlab *PS = (PoolSlab*)malloc(PageSize);
+ unsigned Size = Pool->AllocSize;
+ Pool->AllocSize <<= 1;
+ PoolSlab *PS = (PoolSlab*)malloc(Size);
// Add the body of the slab to the free list...
FreedNodeHeader *SlabBody = (FreedNodeHeader*)(PS+1);
- SlabBody->Size = PageSize-sizeof(PoolSlab)-sizeof(FreedNodeHeader);
+ SlabBody->Size = Size-sizeof(PoolSlab)-sizeof(FreedNodeHeader);
SlabBody->NormalHeader.Next = Pool->FreeNodeList;
Pool->FreeNodeList = SlabBody;
@@ -77,6 +79,7 @@
Pool->Slabs = 0;
Pool->FreeNodeList = 0;
Pool->LargeArrays = 0;
+ Pool->AllocSize = PageSize;
DEBUG(printf("init pool 0x%X\n", Pool));
}
@@ -86,7 +89,8 @@
void pooldestroy(PoolTy *Pool) {
assert(Pool && "Null pool pointer passed in to pooldestroy!\n");
- DEBUG(printf("destroy pool 0x%X\n", Pool));
+ DEBUG(printf("destroy pool 0x%X NextAllocSize = %d\n", Pool,
+ Pool->AllocSize));
// Free all allocated slabs.
PoolSlab *PS = Pool->Slabs;
Index: poolalloc/runtime/FL2Allocator/PoolAllocator.h
diff -u poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.1 poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.2
--- poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.1 Thu Dec 25 13:46:20 2003
+++ poolalloc/runtime/FL2Allocator/PoolAllocator.h Thu Mar 4 22:39:09 2004
@@ -61,6 +61,9 @@
// The list of free'd nodes.
FreedNodeHeader *FreeNodeList;
+
+ // The size to allocate for the next slab.
+ unsigned AllocSize;
};
extern "C" {
More information about the llvm-commits
mailing list