in reply to Re: 32bit/64bit hash function: Use perls internal hash function?
in thread 32bit/64bit hash function: Use perls internal hash function?
My situations is this, any suggestions appreciated, probably someone has done this before:
In some situations perl hashes are bloated in memory usage: Example: store 100million 64 byte keys with 32bit values. If you do this perl uses >50GiB RAM! If you try and do 1billion keys... forget it.
Now I don't need to retrieve the keys or store them in memory (I am given them as input and just want the value back from the key).
So what I am doing is: Hash the key to 2x32bit. Use one 32bit hash as a lookup to an array of 4billion entries. In the array I store the 32bit value and the another 32bits of the hash for collision detection/handling. Result is I can store 100million items in 32GiB RAM. In fact I can store 500million and even push to 2billion items in 32GiB ram. Its only when I approach 4B will re-hashing for collision detecting become a problem.
Obviously to get perls performance, I need a faster hash than md5, benchmarks were showing it was very slow compared to perls internal hash.
The values I fetch are then used to seek to a file/positions on disk, to fetch small amounts of data (<64bytes). I was finding the fastest I could achieve was about 20% of the random IOPS of the SSD, with reads being 8KB. By changing to sysread I have been able to completely eliminate this problem 5x faster and now get IOPS same as SSD benchmark results.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: 32bit/64bit hash function: Use perls internal hash function?
by hv (Prior) on Apr 09, 2022 at 12:04 UTC | |
|
Re^3: 32bit/64bit hash function: Use perls internal hash function?
by Fletch (Bishop) on Apr 09, 2022 at 02:34 UTC | |
by Tux (Canon) on Apr 09, 2022 at 12:28 UTC | |
|
Re^3: 32bit/64bit hash function: Use perls internal hash function?
by eyepopslikeamosquito (Archbishop) on Apr 09, 2022 at 02:36 UTC | |
by sectokia (Friar) on Apr 10, 2022 at 11:11 UTC |