[Issue 17881] Provide mechanism to preallocate memory from the GC
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 28 13:30:48 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=17881
Stanislav Blinov <stanislav.blinov at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |stanislav.blinov at gmail.com
--- Comment #13 from Stanislav Blinov <stanislav.blinov at gmail.com> ---
Created attachment 1713
--> https://issues.dlang.org/attachment.cgi?id=1713&action=edit
Example of paged allocation with GC
Jumping in a year later almost to the hour, I'll start with a disclaimer: I
agree with Andrei that such functionality in general is best left for a custom
allocator API.
That said, having a straightforward utility for chunked GC allocations in
Phobos or DRuntime would benefit users who don't necessarily want to import or
deal with custom allocators for "just that one allocation" (scripts,
prototyping, etc.).
Attached is an implementation of the sketch suggested in previous comments; see
comments in the code about certain implementation/DRuntime quirks. This
implementation on my machine is about 10x faster than piecewise allocation with
both dmd and ldc; it's still slower, of course, than a wholesale preallocation,
but at least should be on the same order of magnitude, unless you go for
astronomical amounts of instances.
--
More information about the Digitalmars-d-bugs
mailing list