[Issue 17881] Provide mechanism to preallocate memory from the GC

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Oct 7 07:37:01 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=17881

Rainer Schuetze <r.sagitario at gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario at gmx.de

--- Comment #5 from Rainer Schuetze <r.sagitario at gmx.de> ---
A slightly simpler API could be to add allocating N same-sized chunks from the
GC that returns them in a free-list-like chain.

I agree with Andrei that we should not complicate the GC interface for every
possible allocation pattern a user might want to optimize for, though.

If you call GC.reserve(20_000_000*(Key.sizeof+Value.sizeof)) before inserting
elements, there should be no collection while filling the AA.

If we add thread local free-lists to the GC, the overhead of allocating these
from the GC instead of caching them in the AA would be rather small.

--


More information about the Digitalmars-d-bugs mailing list