From: Jakob Stoklund Olesen Date: Fri, 4 Jan 2013 22:35:45 +0000 (+0000) Subject: Special case Recycler::clear(BumpPtrAllocator). X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b2e01b3707e23276a087f0f67edfc86082acdaa2;p=oota-llvm.git Special case Recycler::clear(BumpPtrAllocator). A BumpPtrAllocator has an empty Deallocate() method, but Recycler::clear() would still call it for every single object ever allocated, bringing all those objects into cache. As a bonus, iplist::remove() will also write to the Prev/Next pointers on all the objects, so all those cache lines have to be written back to RAM before the pages are given back to the OS. Stop wasting time and memory bandwith by using the new clearAndLeakUnsafely() function to jettison all the recycled objects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171541 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/Recycler.h b/include/llvm/Support/Recycler.h index fa6e189e97b..bcc561db2d5 100644 --- a/include/llvm/Support/Recycler.h +++ b/include/llvm/Support/Recycler.h @@ -22,6 +22,8 @@ namespace llvm { +class BumpPtrAllocator; + /// PrintRecyclingAllocatorStats - Helper for RecyclingAllocator for /// printing statistics. /// @@ -87,6 +89,15 @@ public: } } + /// Special case for BumpPtrAllocator which has an empty Deallocate() + /// function. + /// + /// There is no need to traverse the free list, pulling all the objects into + /// cache. + void clear(BumpPtrAllocator&) { + FreeList.clearAndLeakNodesUnsafely(); + } + template SubClass *Allocate(AllocatorType &Allocator) { assert(sizeof(SubClass) <= Size &&