in reply to Fastest way to lookup a point in a set
I'm late to this party, but did you try a database solution? I would give SQLite a shot.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fastest way to lookup a point in a set
by marioroy (Prior) on Aug 08, 2017 at 20:11 UTC | |
Update: Added SQLite_File for comparison. Hello talexb, The following is a demonstration comparing a plain hash against CDB_File, DB_File. and SQLite_File.
Results: The native Perl on Mac OS X 10.11.6 is v5.18.2. The hardware is a Haswell i7 chip at 2.6 GHz. Regarding CDB_File and DB_File performance, these run better with Perl 5.20 and later releases.
Regards, Mario | [reply] [d/l] [select] |
by talexb (Chancellor) on Aug 08, 2017 at 20:51 UTC | |
Thanks for that .. I wonder what happens when the number of data points increases by a few orders of magnitude? That's where I would expect a database solution to start to overtake the hash-based solution. | [reply] |
by BrowserUk (Patriarch) on Aug 08, 2017 at 21:55 UTC | |
I've run Perl's hashes up to 30 billion keys/2 terabytes (ram) and they are 1 to 2 orders of magnitude faster, and ~1/3rd the size of storing the same data (64-bit integers) in an sqlite memory-based DB. And the performance difference increases as the size grows. Part of the difference is that however fast the C/C++ DB code is, calling into it from Perl, adds a layer of unavoidable overhead that Perl's built-in hashes do not have. The second part is that indexing very large, sparse ranges of data can be done in one of two ways: In the end, O(1) trumps O(log N) and native trumps calling out to C. From compiled-to-native code -- whatever language -- it is possible to tailor solutions to the lookup domain that will out-perform Perl's native hashes. Judy arrays, radix trees, compressed bitmaps, simplified&tailored hash-arrays, but any of those mechanisms fall short once you add the overhead of calling out from Perl. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.
Suck that fhit
| [reply] |
|
Re^2: Fastest way to lookup a point in a set
by erix (Prior) on Aug 08, 2017 at 16:34 UTC | |
did you try a database solution? I did. It was so spectactularly much slower that I didn't bother posting it (and I used postgres). | [reply] |