[llvm-commits] [llvm] r171541 - /llvm/trunk/include/llvm/Support/Recycler.h

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Jan 4 14:35:45 PST 2013


Author: stoklund
Date: Fri Jan  4 16:35:45 2013
New Revision: 171541

URL: http://llvm.org/viewvc/llvm-project?rev=171541&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/Support/Recycler.h

Modified: llvm/trunk/include/llvm/Support/Recycler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Recycler.h?rev=171541&r1=171540&r2=171541&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Recycler.h (original)
+++ llvm/trunk/include/llvm/Support/Recycler.h Fri Jan  4 16:35:45 2013
@@ -22,6 +22,8 @@
 
 namespace llvm {
 
+class BumpPtrAllocator;
+
 /// PrintRecyclingAllocatorStats - Helper for RecyclingAllocator for
 /// printing statistics.
 ///
@@ -87,6 +89,15 @@
     }
   }
 
+  /// 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<class SubClass, class AllocatorType>
   SubClass *Allocate(AllocatorType &Allocator) {
     assert(sizeof(SubClass) <= Size &&





More information about the llvm-commits mailing list