Fast GC allocation of many small objects

Alexandru jercaianu Alex.jercaianu at gmail.com
Sun Apr 1 10:59:55 UTC 2018


On Saturday, 31 March 2018 at 20:17:26 UTC, Per Nordlöw wrote:
> On Friday, 30 March 2018 at 23:09:33 UTC, Alexandru Jercaianu 
> wrote:
>> Hello,
>>
>> You can try the following:
>>     struct Node
>>     {
>>         char[64] arr;
>>     }
>>
>>      enum numNodes = 100_000_000;
>>      void[] buf = GCAllocator.instance.allocate(numNodes * 
>> Node.sizeof);
>>      auto reg = Region!(NullAllocator, 16)(cast(ubyte[])buf);
>
> Thanks!
>
> Is a `minAlign` of 16 recommended over 8 when allocating 
> classes or arrays?
Hi,
I'm glad it was helpful.
To be honest, I don't know which alignment would be better and it 
probably depends on your machine.
This here says that 16 would work just fine [1] so I would go 
with that.

[1] - 
https://dlang.org/library/std/experimental/allocator/common/platform_alignment.html


More information about the Digitalmars-d-learn mailing list