"Faster than Rust and C++: the PERFECT hash table"

Siarhei Siamashka siarhei.siamashka at gmail.com
Mon Dec 11 11:21:46 UTC 2023


On Monday, 11 December 2023 at 03:25:15 UTC, Christopher Katko 
wrote:
>  I wonder how easy it would be to slap it into D to test. Do 
> you just override the toHash function in your objects or is 
> there more to it?

The "faster than Rust" achievement doesn't mean much in reality, 
because the hash function in Rust is DoS-resistant by default. 
There's an old bug about a related issue in D: 
https://issues.dlang.org/show_bug.cgi?id=7179

D language lacks flexibility in this area and replacing the 
built-in associative arrays hash function doesn't seem like an 
easy task. Moreover, there's now the 
https://dlang.org/changelog/2.106.0.html#dmd.static-assoc-array 
feature and CTFE makes everything even more tricky. Reminds me of 
the old prelink vs. ASLR dilemma: https://lwn.net/Articles/190139/

One the other hand, it's possible to leave the built-in 
associative arrays alone and design a custom container class with 
a custom hash function. Tailored either for maximum performance 
or for DoS-resistance.


More information about the Digitalmars-d mailing list