From b1e54295ef9a319d16ab55e1938501d3ebac7aa4 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Sun, 28 Jul 2024 23:54:33 +0000 Subject: [PATCH] Use new faster fxhash. This was implemented in https://github.com/rust-lang/rustc-hash/pull/37 by Orson Peters and benchmarked in https://github.com/rust-lang/rust/pull/125133. --- Cargo.lock | 24 ++++++++++++++-------- compiler/rustc_data_structures/Cargo.toml | 2 +- compiler/rustc_pattern_analysis/Cargo.toml | 2 +- compiler/rustc_span/src/def_id.rs | 9 +------- src/rustdoc-json-types/Cargo.toml | 2 +- src/tools/jsondoclint/Cargo.toml | 2 +- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32470c22f29f1..0c79b27a51899 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1309,7 +1309,7 @@ dependencies = [ "fluent-syntax", "intl-memoizer", "intl_pluralrules", - "rustc-hash", + "rustc-hash 1.1.0", "self_cell 0.10.3", "smallvec", "unic-langid", @@ -2019,7 +2019,7 @@ dependencies = [ "anyhow", "clap", "fs-err", - "rustc-hash", + "rustc-hash 2.0.0", "rustdoc-json-types", "serde", "serde_json", @@ -2290,7 +2290,7 @@ dependencies = [ "memmap2", "parking_lot", "perf-event-open-sys", - "rustc-hash", + "rustc-hash 1.1.0", "smallvec", ] @@ -2934,7 +2934,7 @@ checksum = "c4e8e505342045d397d0b6674dcb82d6faf5cf40484d30eeb88fc82ef14e903f" dependencies = [ "datafrog", "log", - "rustc-hash", + "rustc-hash 1.1.0", ] [[package]] @@ -3372,6 +3372,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc-main" version = "0.0.0" @@ -3761,7 +3767,7 @@ dependencies = [ "memmap2", "parking_lot", "portable-atomic", - "rustc-hash", + "rustc-hash 2.0.0", "rustc-rayon", "rustc-stable-hash", "rustc_arena", @@ -4452,7 +4458,7 @@ dependencies = [ name = "rustc_pattern_analysis" version = "0.0.0" dependencies = [ - "rustc-hash", + "rustc-hash 2.0.0", "rustc_apfloat", "rustc_arena", "rustc_data_structures", @@ -4843,7 +4849,7 @@ name = "rustdoc-json-types" version = "0.1.0" dependencies = [ "bincode", - "rustc-hash", + "rustc-hash 2.0.0", "serde", "serde_json", ] @@ -5557,7 +5563,7 @@ dependencies = [ "ignore", "miropt-test-tools", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "semver", "similar", "termcolor", @@ -5786,7 +5792,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb68604048ff8fa93347f02441e4487594adc20bb8a084f9e564d2b827a0a9f" dependencies = [ - "rustc-hash", + "rustc-hash 1.1.0", ] [[package]] diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index 3794a6e043c6d..25f2f84faa8a9 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -13,7 +13,7 @@ ena = "0.14.3" indexmap = { version = "2.0.0" } jobserver_crate = { version = "0.1.28", package = "jobserver" } measureme = "11" -rustc-hash = "1.1.0" +rustc-hash = "2.0.0" rustc-rayon = { version = "0.5.0", optional = true } rustc-stable-hash = { version = "0.1.0", features = ["nightly"] } rustc_arena = { path = "../rustc_arena" } diff --git a/compiler/rustc_pattern_analysis/Cargo.toml b/compiler/rustc_pattern_analysis/Cargo.toml index 0cb47e03441ba..34fb1bdf6fa79 100644 --- a/compiler/rustc_pattern_analysis/Cargo.toml +++ b/compiler/rustc_pattern_analysis/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] # tidy-alphabetical-start -rustc-hash = "1.1.0" +rustc-hash = "2.0.0" rustc_apfloat = "0.2.0" rustc_arena = { path = "../rustc_arena", optional = true } rustc_data_structures = { path = "../rustc_data_structures", optional = true } diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 5456303b36fe4..e8bc2b59a620d 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -252,14 +252,7 @@ impl !PartialOrd for DefId {} // +-------------------+-------------------+ // ``` // -// The order here has direct impact on `FxHash` quality because we have far more `DefIndex` per -// crate than we have `Crate`s within one compilation. Or in other words, this arrangement puts -// more entropy in the low bits than the high bits. The reason this matters is that `FxHash`, which -// is used throughout rustc, has problems distributing the entropy from the high bits, so reversing -// the order would lead to a large number of collisions and thus far worse performance. -// -// On 64-bit big-endian systems, this compiles to a 64-bit rotation by 32 bits, which is still -// faster than another `FxHash` round. +// On 64-bit big-endian systems, this compiles to a 64-bit rotation by 32 bits, or a 64-bit load. #[cfg(target_pointer_width = "64")] impl Hash for DefId { fn hash(&self, h: &mut H) { diff --git a/src/rustdoc-json-types/Cargo.toml b/src/rustdoc-json-types/Cargo.toml index d3548036d4c72..4222de200ba23 100644 --- a/src/rustdoc-json-types/Cargo.toml +++ b/src/rustdoc-json-types/Cargo.toml @@ -8,7 +8,7 @@ path = "lib.rs" [dependencies] serde = { version = "1.0", features = ["derive"] } -rustc-hash = "1.1.0" +rustc-hash = "2.0.0" [dev-dependencies] serde_json = "1.0" diff --git a/src/tools/jsondoclint/Cargo.toml b/src/tools/jsondoclint/Cargo.toml index 1318a1f447620..cc8ecefd530b4 100644 --- a/src/tools/jsondoclint/Cargo.toml +++ b/src/tools/jsondoclint/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0.62" clap = { version = "4.0.15", features = ["derive"] } fs-err = "2.8.1" -rustc-hash = "1.1.0" +rustc-hash = "2.0.0" rustdoc-json-types = { version = "0.1.0", path = "../../rustdoc-json-types" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.85"