Re: Fast GC allocation of many small objects

2018-04-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/2/18 2:51 PM, Per Nordlöw wrote: On Monday, 2 April 2018 at 18:22:43 UTC, Steven Schveighoffer wrote: You may be interested in this proposal, which was inspired by trying to implement a reserve feature for AAs (requires a similar mechanism). https://issues.dlang.org/show_bug.cgi?id=17881

Re: Fast GC allocation of many small objects

2018-04-02 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 2 April 2018 at 18:22:43 UTC, Steven Schveighoffer wrote: You may be interested in this proposal, which was inspired by trying to implement a reserve feature for AAs (requires a similar mechanism). https://issues.dlang.org/show_bug.cgi?id=17881 Ok, thanks. I'll push for it. One

Re: Fast GC allocation of many small objects

2018-04-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/30/18 4:31 PM, Per Nordlöw wrote: I'm working on a graph database with tens of millions of small nodes containing typically around 8-64 bytes of member data. Is there a faster way of allocating many small class objects such as class Node {     // abstract members } class StrNode : Node

Re: Fast GC allocation of many small objects

2018-04-01 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 1 April 2018 at 10:59:55 UTC, Alexandru jercaianu wrote: 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; }

Re: Fast GC allocation of many small objects

2018-04-01 Thread Alexandru jercaianu via Digitalmars-d-learn
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 =

Re: Fast GC allocation of many small objects

2018-03-31 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 31 March 2018 at 20:17:26 UTC, Per Nordlöw wrote: auto reg = Region!(NullAllocator, 16)(cast(ubyte[])buf); Thanks! Turns out that Region allocator wasn't fully qualified: https://github.com/dlang/phobos/pull/6400 This will make it possible to allocate with it in pure code

Re: Fast GC allocation of many small objects

2018-03-31 Thread Per Nordlöw via Digitalmars-d-learn
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 =

Re: Fast GC allocation of many small objects

2018-03-31 Thread Seb via Digitalmars-d-learn
On Saturday, 31 March 2018 at 19:38:31 UTC, Per Nordlöw wrote: On Saturday, 31 March 2018 at 19:31:37 UTC, Rubn wrote: Be willing to change your code, the allocator can change at any point. What you implement today may not work tomorrow, what you fix to work for tomorrow may not end up working

Re: Fast GC allocation of many small objects

2018-03-31 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 31 March 2018 at 19:31:37 UTC, Rubn wrote: Be willing to change your code, the allocator can change at any point. What you implement today may not work tomorrow, what you fix to work for tomorrow may not end up working the next day (in terms of releases). That really should be

Re: Fast GC allocation of many small objects

2018-03-31 Thread Rubn via Digitalmars-d-learn
On Friday, 30 March 2018 at 20:46:43 UTC, Per Nordlöw wrote: On Friday, 30 March 2018 at 20:38:35 UTC, rikki cattermole wrote: Use a custom allocator (that could be backed by the GC) using std.experimental.allocators :) https://dlang.org/phobos/std_experimental_allocator.html is massive. I

Re: Fast GC allocation of many small objects

2018-03-31 Thread Rémy Mouëza via Digitalmars-d-learn
On Saturday, 31 March 2018 at 09:10:13 UTC, Boris-Barboris wrote: On Friday, 30 March 2018 at 20:31:35 UTC, Per Nordlöw wrote: Is there a faster way of allocating many small class objects such as... maybe something like this: import std.conv: to; import std.stdio; class Node {} class

Re: Fast GC allocation of many small objects

2018-03-31 Thread Boris-Barboris via Digitalmars-d-learn
On Friday, 30 March 2018 at 20:31:35 UTC, Per Nordlöw wrote: Is there a faster way of allocating many small class objects such as... maybe something like this: import std.conv: to; import std.stdio; class Node {} class StrNode : Node { string value; } void main() {

Re: Fast GC allocation of many small objects

2018-03-30 Thread Alexandru Jercaianu via Digitalmars-d-learn
On Friday, 30 March 2018 at 23:09:33 UTC, Alexandru Jercaianu wrote: On Friday, 30 March 2018 at 20:46:43 UTC, Per Nordlöw wrote: On Friday, 30 March 2018 at 20:38:35 UTC, rikki cattermole wrote: Use a custom allocator (that could be backed by the GC) using std.experimental.allocators :)

Re: Fast GC allocation of many small objects

2018-03-30 Thread Alexandru Jercaianu via Digitalmars-d-learn
On Friday, 30 March 2018 at 20:46:43 UTC, Per Nordlöw wrote: On Friday, 30 March 2018 at 20:38:35 UTC, rikki cattermole wrote: Use a custom allocator (that could be backed by the GC) using std.experimental.allocators :) https://dlang.org/phobos/std_experimental_allocator.html is massive. I

Re: Fast GC allocation of many small objects

2018-03-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/03/2018 9:46 AM, Per Nordlöw wrote: On Friday, 30 March 2018 at 20:38:35 UTC, rikki cattermole wrote: Use a custom allocator (that could be backed by the GC) using std.experimental.allocators :) https://dlang.org/phobos/std_experimental_allocator.html is massive. I guess I should

Re: Fast GC allocation of many small objects

2018-03-30 Thread Per Nordlöw via Digitalmars-d-learn
On Friday, 30 March 2018 at 20:38:35 UTC, rikki cattermole wrote: Use a custom allocator (that could be backed by the GC) using std.experimental.allocators :) https://dlang.org/phobos/std_experimental_allocator.html is massive. I guess I should allocate my nodes using auto node =

Re: Fast GC allocation of many small objects

2018-03-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/03/2018 9:31 AM, Per Nordlöw wrote: I'm working on a graph database with tens of millions of small nodes containing typically around 8-64 bytes of member data. Is there a faster way of allocating many small class objects such as class Node {     // abstract members } class StrNode :