[llvm-commits] [PATCH] ArrayRecycler

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


Please review this patch which adds an ArrayRecycler class to Support.

The class works a lot like the existing Recycler class, except it recycles arrays instead of single objects. Array capacities are picked from a small predetermined set, currently powers of 2.

This class will be used to manage the memory used for the MachineOperand lists on MachineInstrs. The purpose is to reduce malloc traffic, and to enable the pool allocation pattern. If MachineInstrs and MachineOperands are all allocated from the same BumpPtrAllocator, and if they have trivial destructors, a whole MachineFunction can be deallocated very quickly by simply zapping the BumpPtrAllocator.

I left out some features pending further analysis and performance measurements:

- Provide more small array sizes instead of just powers of 2. This would save some memory, but could cause more reallocations. (Part of the raison d'ĂȘtre of the Capacity class is to enable array size tinkering without changing clients).

- Recycle available arrays larger than the requested size by breaking them into smaller pieces. This could reduce memory usage at the risk of turning into malloc().


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-an-ArrayRecycler-class.patch
Type: application/octet-stream
Size: 9238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130104/9be9ab8f/attachment.obj>

More information about the llvm-commits mailing list