summaryrefslogtreecommitdiffstats
path: root/third_party/rust/fxhash/README.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/fxhash/README.md
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/fxhash/README.md')
-rw-r--r--third_party/rust/fxhash/README.md62
1 files changed, 62 insertions, 0 deletions
diff --git a/third_party/rust/fxhash/README.md b/third_party/rust/fxhash/README.md
new file mode 100644
index 0000000000..672568ab12
--- /dev/null
+++ b/third_party/rust/fxhash/README.md
@@ -0,0 +1,62 @@
+# Fx Hash
+
+This hashing algorithm was extracted from the Rustc compiler. This is the same hashing algoirthm used for some internal operations in FireFox. The strength of this algorithm is in hashing 8 bytes at a time on 64-bit platforms, where the FNV algorithm works on one byte at a time.
+
+## Disclaimer
+
+It is **not a cryptographically secure** hash, so it is strongly recommended that you do not use this hash for cryptographic purproses. Furthermore, this hashing algorithm was not designed to prevent any attacks for determining collisions which could be used to potentially cause quadratic behavior in `HashMap`s. So it is not recommended to expose this hash in places where collissions or DDOS attacks may be a concern.
+
+## Examples
+
+Building an Fx backed hashmap.
+
+```rust
+extern crate fxhash;
+use fxhash::FxHashMap;
+
+let mut hashmap = FxHashMap::new();
+
+hashmap.insert("black", 0);
+hashmap.insert("white", 255);
+```
+
+Building an Fx backed hashset.
+
+```rust
+extern crate fxhash;
+use fxhash::FxHashSet;
+
+let mut hashmap = FxHashSet::new();
+
+hashmap.insert("black");
+hashmap.insert("white");
+```
+
+## Benchmarks
+
+Generally `fxhash` is than `fnv` on `u32`, `u64`, or any byte sequence with length >= 5. However, keep in mind that hashing speed is not the only characteristic worth considering. That being said, Rustc had an observable increase in speed when switching from `fnv` backed hashmaps to `fx` based hashmaps.
+
+ bench_fnv_003 ... bench: 3 ns/iter (+/- 0)
+ bench_fnv_004 ... bench: 2 ns/iter (+/- 0)
+ bench_fnv_011 ... bench: 6 ns/iter (+/- 1)
+ bench_fnv_012 ... bench: 5 ns/iter (+/- 1)
+ bench_fnv_023 ... bench: 14 ns/iter (+/- 3)
+ bench_fnv_024 ... bench: 14 ns/iter (+/- 4)
+ bench_fnv_068 ... bench: 57 ns/iter (+/- 11)
+ bench_fnv_132 ... bench: 145 ns/iter (+/- 30)
+ bench_fx_003 ... bench: 4 ns/iter (+/- 0)
+ bench_fx_004 ... bench: 3 ns/iter (+/- 1)
+ bench_fx_011 ... bench: 5 ns/iter (+/- 2)
+ bench_fx_012 ... bench: 4 ns/iter (+/- 1)
+ bench_fx_023 ... bench: 7 ns/iter (+/- 3)
+ bench_fx_024 ... bench: 4 ns/iter (+/- 1)
+ bench_fx_068 ... bench: 10 ns/iter (+/- 3)
+ bench_fx_132 ... bench: 19 ns/iter (+/- 5)
+ bench_seahash_003 ... bench: 30 ns/iter (+/- 12)
+ bench_seahash_004 ... bench: 32 ns/iter (+/- 22)
+ bench_seahash_011 ... bench: 30 ns/iter (+/- 4)
+ bench_seahash_012 ... bench: 31 ns/iter (+/- 1)
+ bench_seahash_023 ... bench: 32 ns/iter (+/- 6)
+ bench_seahash_024 ... bench: 31 ns/iter (+/- 5)
+ bench_seahash_068 ... bench: 40 ns/iter (+/- 9)
+ bench_seahash_132 ... bench: 50 ns/iter (+/- 12) \ No newline at end of file