PLC-lang / rusty

Structured Text Parser and LLVM Frontend
GNU Lesser General Public License v3.0
181 stars 47 forks source link

perf: Use non-cryptographic FxHash algorithm #1202

Closed volsa closed 2 weeks ago

volsa commented 1 month ago

Use the non-cryptographic FxHash algorithm for HashMaps, reducing the plc check times by a few hundred milliseconds; also used in rustc

From https://github.com/rust-lang/rustc-hash

A speedy, non-cryptographic hashing algorithm used by rustc and Firefox. The hash map in std uses SipHash by default, which provides resistance against DOS attacks. These attacks aren't as much of a concern in the compiler so we prefer to use the quicker, non-cryptographic Fx algorithm.

The Fx algorithm is a unique one used by Firefox. It is fast because it can hash eight bytes at a time. Within rustc, it consistently outperforms every other tested algorithm (such as FNV). The collision rate is similar or slightly worse than other low-quality hash functions.