TempAlloc review starts now

KennyTM~ kennytm at gmail.com
Mon Jun 6 01:54:35 PDT 2011


On Jun 6, 11 06:25, Lars T. Kyllingstad wrote:
> All right, folks, it's time to get the review queue started again.  First
> up is David Simcha's TempAlloc, which, if accepted, is to be included in
> the core.memory module in druntime.
>
> If there are no objections, I suggest we use 3 weeks (until 27 June) for
> the review, followed by one week for voting.  Please post reviews in this
> thread.
>
> Here follows a description of TempAlloc's purpose and functionality.
> Links to the code and documentation are at the bottom.
>
> -Lars
>
>
> David Simcha wrote:
>
> TempAlloc is a thread-local segmented stack memory allocator
> (defined/detailed in the docs) for efficiently allocating temporary
> buffers, matrices, etc.  It has the following advantages compared to
> allocation on the call stack:
>
> 1. Pointers to memory allocated on the TempAlloc stack are still valid
> when the function they were allocated from returns. Functions can be
> written to create and return data structures on the TempAlloc stack.
>
> 2. Since it is a segmented stack, large allocations can be performed with
> no danger of stack overflow errors.
>
> It has the following advantages compared to heap allocation:
>
> 1. Both allocation and deallocation are extremely fast. Most allocations
> consist of verifying enough space is available, incrementing a pointer and
> a performing a few cheap bookkeeping operations. Most deallocations
> consist decrementing a pointer and performing a few cheap bookkeeping
> operations.
>
> 2. The segmented stack is thread-local, so synchronization is only needed
> when a segment needs to be allocated or freed.
>
> 3. Fragmentation is not an issue when allocating memory on the TempAlloc
> stack, though it can be an issue when trying to allocate a new segment.
>
> It'd be nice to get this in the next release b/c SciD, which is being
> worked on extensively for GSoC, uses it and Don said he wanted to use it
> in BigInt.
>
> Code:
>
> https://github.com/dsimcha/TempAlloc/blob/master/tempalloc.d
>
> Docs:
>
> http://cis.jhu.edu/~dsimcha/d/phobos/core_tempalloc.html

Can't access the doc, it's 404.


More information about the Digitalmars-d mailing list