Memory Efficient HashSet

Nordlöw via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 9 14:31:50 PST 2016


On Tuesday, 8 March 2016 at 12:25:36 UTC, Ola Fosheim Grøstad 
wrote:
> On Tuesday, 8 March 2016 at 08:12:04 UTC, Nordlöw wrote:
>> sparse_hash_set<> contained in
>>
>> https://github.com/sparsehash/sparsehash
>
> It appears to be very slow?
> What do you need it for?

My knowledge database engine I'm building cannot afford the 
memory overhead of D's builtin associative arrays.

For instance the following program

void main(string[] args)
{
     alias T = uint;
     bool[T] x; // emulates a HashSet with significant memory 
overhead
     import std.range : iota;
     const n = 10_000_000;
     foreach (const i; iota(0, n))
     {
         x[i] = true; // indicate that it's stored
     }

     import std.stdio : writeln, readln;
     writeln("Press return: ");
     readln;
}

consumes 842.m MiB on my Ubuntu.

The consumption with Google's sparsehash unordered_set is about 
50 MiB.


More information about the Digitalmars-d-learn mailing list