I think for now it is not worth considering adding hashflooding mitigation to the Roc Dict.
1. Wyhash is a secure enough has to pass SMHasher.
2. Languages like Go use wyhash in production and have not seen hashflooding issues.
3. We do have a random seed that Dicts use that changes per application linking. (Could monomorphize on Dict type for more randomness)
4. Any sort of fallback checks will lead to worse performance in the normal case.
5. A reasonable http server or app can limit the size of JSON or number of HTTP headers to accept.
ankerl::dense_unordered is a very fast hash map that is built to be an index map.
This enables extra optimizations compared to just wrapping a regular hash map.
As such, I think this map is very well suited for our index map impl in Roc.
I also think this dictionary implementation is simpler overall.
On top of that, this removes the need for SIMD instructions for peak performance.
Benchmarks of the C++ version and other C++ hash maps are here: https://martin.ankerl.com/2022/08/27/hashmap-bench-01/
Though this has clear bias of being written by the author of ankerl::dense_unordered,
the results all look correct and the benchmarks thorough.
I think for now it is not worth considering adding hashflooding mitigation to the Roc Dict.
1. Wyhash is a secure enough has to pass SMHasher.
2. Languages like Go use wyhash in production and have not seen hashflooding issues.
3. We do have a random seed that Dicts use that changes per application linking. (Could monomorphize on Dict type for more randomness)
4. Any sort of fallback checks will lead to worse performance in the normal case.
5. A reasonable http server or app can limit the size of JSON or number of HTTP headers to accept.
ankerl::dense_unordered is a very fast hash map that is built to be an index map.
This enables extra optimizations compared to just wrapping a regular hash map.
As such, I think this map is very well suited for our index map impl in Roc.
I also think this dictionary implementation is simpler overall.
On top of that, this removes the need for SIMD instructions for peak performance.
Benchmarks of the C++ version and other C++ hash maps are here: https://martin.ankerl.com/2022/08/27/hashmap-bench-01/
Though this has clear bias of being written by the author of ankerl::dense_unordered,
the results all look correct and the benchmarks thorough.