Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PERF EXPERIMENTS] Hashmap experiment #120151

Closed
wants to merge 2 commits into from

Conversation

Noratrieb
Copy link
Member

I've been thinking about some sort of more efficient way of dealing with small hashmaps, since the vast majority of hashmaps are small..

(non-empty maps only)

    0.5..=      1:       0 (0.0%)
      1..=      2:      15 (0.0061269%)
      2..=      4:  176617 (72.14%)
      4..=      8:  203093 (82.955%)
      8..=     16:  232412 (94.93%)
     16..=     32:  240221 (98.12%)
     32..=     64:  243007 (99.258%)
     64..=    128:  244165 (99.731%)
    128..=    256:  244512 (99.873%)
    256..=    512:  244692 (99.946%)
    512..=   1024:  244734 (99.963%)
   1024..=   2048:  244763 (99.975%)
   2048..=   4096:  244780 (99.982%)
   4096..=   8192:  244795 (99.988%)
   8192..=  16384:  244808 (99.993%)
  16384..=  32768:  244816 (99.997%)

let's try something with the most popular small map

r? @ghost

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 19, 2024
@Noratrieb
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 19, 2024
@Noratrieb Noratrieb added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 19, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 19, 2024
[PERF EXPERIMENTS] Hashmap experiment

I've been thinking about some sort of more efficient way of dealing with small hashmaps, since the vast majority of hashmaps are small..

(non-empty maps only)
```
    0.5..=      1:       0 (0.0%)
      1..=      2:      15 (0.0061269%)
      2..=      4:  176617 (72.14%)
      4..=      8:  203093 (82.955%)
      8..=     16:  232412 (94.93%)
     16..=     32:  240221 (98.12%)
     32..=     64:  243007 (99.258%)
     64..=    128:  244165 (99.731%)
    128..=    256:  244512 (99.873%)
    256..=    512:  244692 (99.946%)
    512..=   1024:  244734 (99.963%)
   1024..=   2048:  244763 (99.975%)
   2048..=   4096:  244780 (99.982%)
   4096..=   8192:  244795 (99.988%)
   8192..=  16384:  244808 (99.993%)
  16384..=  32768:  244816 (99.997%)
```

let's try something with the most popular small map

r? `@ghost`
@bors
Copy link
Contributor

bors commented Jan 19, 2024

⌛ Trying commit 93b0a1a with merge b5e8a3a...

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 19, 2024

💔 Test failed - checks-actions

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 19, 2024
@Noratrieb
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 20, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 20, 2024
[PERF EXPERIMENTS] Hashmap experiment

I've been thinking about some sort of more efficient way of dealing with small hashmaps, since the vast majority of hashmaps are small..

(non-empty maps only)
```
    0.5..=      1:       0 (0.0%)
      1..=      2:      15 (0.0061269%)
      2..=      4:  176617 (72.14%)
      4..=      8:  203093 (82.955%)
      8..=     16:  232412 (94.93%)
     16..=     32:  240221 (98.12%)
     32..=     64:  243007 (99.258%)
     64..=    128:  244165 (99.731%)
    128..=    256:  244512 (99.873%)
    256..=    512:  244692 (99.946%)
    512..=   1024:  244734 (99.963%)
   1024..=   2048:  244763 (99.975%)
   2048..=   4096:  244780 (99.982%)
   4096..=   8192:  244795 (99.988%)
   8192..=  16384:  244808 (99.993%)
  16384..=  32768:  244816 (99.997%)
```

let's try something with the most popular small map

r? `@ghost`
@bors
Copy link
Contributor

bors commented Jan 20, 2024

⌛ Trying commit f8cb67c with merge 67af906...

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-16 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Built container sha256:9c3c93a371e5aed5c18185b24f130d95d5140dbd72a9b325e7b6b49e521a4faa
Looks like docker image is the same as before, not uploading
https://ci-caches.rust-lang.org/docker/7ebc15c01a233894034d277c8cce4e949f4e7791f66b4727c8fb6e058a0b8171d6152e1441d677cef0653843ceeee469c097b8699b2bb74249e674f6aa1a8813
sha256:9c3c93a371e5aed5c18185b24f130d95d5140dbd72a9b325e7b6b49e521a4faa
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-16]
##[group]Clock drift check
  local time: Sat Jan 20 10:44:45 UTC 2024
  network time: Sat, 20 Jan 2024 10:44:45 GMT
  network time: Sat, 20 Jan 2024 10:44:45 GMT
##[endgroup]
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-16', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'build.optimized-compiler-builtins', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-16/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id            := 99999999
---
   Compiling rustc_middle v0.0.0 (/checkout/compiler/rustc_middle)
   Compiling rustc_ast_passes v0.0.0 (/checkout/compiler/rustc_ast_passes)
   Compiling rustc_expand v0.0.0 (/checkout/compiler/rustc_expand)
   Compiling rustc_builtin_macros v0.0.0 (/checkout/compiler/rustc_builtin_macros)
error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, rustc_type_ir::WithCachedTypeInfo<rustc_type_ir::TyKind<context::TyCtxt<'_>>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
    |
191 |             type_: Default::default(),
    |                    ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, WithCachedTypeInfo<TyKind<TyCtxt<'_>>>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, WithCachedTypeInfo<TyKind<TyCtxt<'_>>>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-660433482206163626.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<ty::consts::Const<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
192 |             const_lists: Default::default(),
192 |             const_lists: Default::default(),
    |                          ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<ty::consts::Const<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, List<Const<'_>>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-8553131298415297507.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<generic_args::GenericArg<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
193 |             args: Default::default(),
193 |             args: Default::default(),
    |                   ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, List<GenericArg<'_>>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, List<GenericArg<'_>>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-17563690996385314126.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<ty::Ty<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
194 |             type_lists: Default::default(),
194 |             type_lists: Default::default(),
    |                         ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<ty::Ty<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<ahash::hash_map::AHashMap<InternedInSet<'_, list::List<ty::Ty<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>>` to implement `std::default::Default`

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, rustc_type_ir::RegionKind<context::TyCtxt<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
195 |             region: Default::default(),
195 |             region: Default::default(),
    |                     ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, RegionKind<TyCtxt<'_>>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, RegionKind<TyCtxt<'_>>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-2914216197105551285.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<sty::Binder<'_, ExistentialPredicate<'_>>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
196 |             poly_existential_predicates: Default::default(),
196 |             poly_existential_predicates: Default::default(),
    |                                          ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, List<Binder<'_, ExistentialPredicate<'_>>>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, List<Binder<'_, ExistentialPredicate<'_>>>>, (), BuildHasherDefault<...>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-5858239116559284810.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<rustc_type_ir::CanonicalVarInfo<context::TyCtxt<'_>>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
197 |             canonical_var_infos: Default::default(),
197 |             canonical_var_infos: Default::default(),
    |                                  ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, List<CanonicalVarInfo<TyCtxt<'_>>>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, List<CanonicalVarInfo<TyCtxt<'_>>>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-9586686905306903960.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, rustc_type_ir::WithCachedTypeInfo<sty::Binder<'_, rustc_type_ir::PredicateKind<context::TyCtxt<'_>>>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
198 |             predicate: Default::default(),
198 |             predicate: Default::default(),
    |                        ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, WithCachedTypeInfo<Binder<'_, PredicateKind<TyCtxt<'_>>>>>, (), ...>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, WithCachedTypeInfo<Binder<'_, PredicateKind<TyCtxt<'_>>>>>, (), ...>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-10630301956561789701.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<ty::Clause<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
199 |             clauses: Default::default(),
199 |             clauses: Default::default(),
    |                      ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<ty::Clause<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<ahash::hash_map::AHashMap<InternedInSet<'_, list::List<ty::Clause<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>>` to implement `std::default::Default`

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<syntax::ProjectionElem<(), ()>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
200 |             projs: Default::default(),
200 |             projs: Default::default(),
    |                    ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, List<ProjectionElem<(), ()>>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, List<ProjectionElem<(), ()>>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-1342279460767018590.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<syntax::ProjectionElem<mir::Local, ty::Ty<'_>>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
    |
201 |             place_elems: Default::default(),
    |                          ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, List<ProjectionElem<Local, Ty<'_>>>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, List<ProjectionElem<Local, Ty<'_>>>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-6348208808084806922.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, rustc_type_ir::WithCachedTypeInfo<ConstData<'_>>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
    |
202 |             const_: Default::default(),
    |                     ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, WithCachedTypeInfo<ConstData<'_>>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, WithCachedTypeInfo<ConstData<'_>>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-6891870272801150056.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, Allocation>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
203 |             const_allocation: Default::default(),
203 |             const_allocation: Default::default(),
    |                               ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `ahash::hash_map::AHashMap<InternedInSet<'_, Allocation>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<ahash::hash_map::AHashMap<InternedInSet<'_, Allocation>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>>` to implement `std::default::Default`

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<BoundVariableKind>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
204 |             bound_variable_kinds: Default::default(),
204 |             bound_variable_kinds: Default::default(),
    |                                   ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<BoundVariableKind>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<ahash::hash_map::AHashMap<InternedInSet<'_, list::List<BoundVariableKind>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>>` to implement `std::default::Default`

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, rustc_target::abi::LayoutS<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
205 |             layout: Default::default(),
205 |             layout: Default::default(),
    |                     ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, LayoutS<FieldIdx, VariantIdx>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, LayoutS<FieldIdx, VariantIdx>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-13224441214798825029.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, adt::AdtDefData>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
206 |             adt_def: Default::default(),
206 |             adt_def: Default::default(),
    |                      ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `ahash::hash_map::AHashMap<InternedInSet<'_, adt::AdtDefData>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<ahash::hash_map::AHashMap<InternedInSet<'_, adt::AdtDefData>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>>` to implement `std::default::Default`

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, ExternalConstraintsData<'_>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
207 |             external_constraints: Default::default(),
207 |             external_constraints: Default::default(),
    |                                   ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `ahash::hash_map::AHashMap<InternedInSet<'_, ExternalConstraintsData<'_>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<ahash::hash_map::AHashMap<InternedInSet<'_, ExternalConstraintsData<'_>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>>` to implement `std::default::Default`

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, PredefinedOpaquesData<'_>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
208 |             predefined_opaques_in_body: Default::default(),
208 |             predefined_opaques_in_body: Default::default(),
    |                                         ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `ahash::hash_map::AHashMap<InternedInSet<'_, PredefinedOpaquesData<'_>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<ahash::hash_map::AHashMap<InternedInSet<'_, PredefinedOpaquesData<'_>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>>` to implement `std::default::Default`

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<rustc_target::abi::FieldIdx>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
209 |             fields: Default::default(),
209 |             fields: Default::default(),
    |                     ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<rustc_target::abi::FieldIdx>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, List<FieldIdx>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-9506897698782892614.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<rustc_span::def_id::LocalDefId>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
    |
210 |             local_def_ids: Default::default(),
    |                            ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, List<LocalDefId>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, List<LocalDefId>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-10725969573053830791.txt'

error[E0277]: the trait bound `ahash::hash_map::AHashMap<InternedInSet<'_, list::List<(rustc_target::abi::VariantIdx, rustc_target::abi::FieldIdx)>>, (), BuildHasherDefault<ahash::fallback_hash::AHasher>>: std::default::Default` is not satisfied
    |
211 |             offset_of: Default::default(),
211 |             offset_of: Default::default(),
    |                        ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `AHashMap<InternedInSet<'_, List<(VariantIdx, FieldIdx)>>, (), BuildHasherDefault<AHasher>>`
    |
    = help: the trait `std::default::Default` is implemented for `ahash::hash_map::AHashMap<K, V>`
    = note: required for `Sharded<AHashMap<InternedInSet<'_, List<(VariantIdx, FieldIdx)>>, (), BuildHasherDefault<AHasher>>>` to implement `std::default::Default`
    = note: the full type name has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-e7916888bc732f66.long-type-1420494774726451531.txt'
For more information about this error, try `rustc --explain E0277`.
error: could not compile `rustc_middle` (lib) due to 21 previous errors
warning: build failed, waiting for other jobs to finish...
Build completed unsuccessfully in 0:01:14

@ChrisDenton
Copy link
Member

From the table it sounds like a VecMap might be better for 99% of cases. Terrible for the <1% though.

@@ -224,7 +223,7 @@ impl<K: Eq + Hash + Copy + IntoPointer> ShardedHashMap<K, ()> {

#[inline]
pub fn make_hash<K: Hash + ?Sized>(val: &K) -> u64 {
let mut state = FxHasher::default();
let mut state = ahash::AHasher::default();
Copy link
Member

@bjorn3 bjorn3 Jan 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahash doesn't guarantee determinism of the hash between platforms and versions. This will likely lead to build artifacts that can't be reproduced unless rustc runs on the exact same architecture and likely lead to diagnostics changing between targets. The latter is something we should fix with more sorting anyway, but the former isn't easily avoidable I think.

@mati865
Copy link
Contributor

mati865 commented Jan 21, 2024

From the table it sounds like a VecMap might be better for 99% of cases. Terrible for the <1% though.

BTreeMap should be good as well assuming Ord is easy to provide.

@bors
Copy link
Contributor

bors commented Feb 14, 2024

☔ The latest upstream changes (presumably #120454) made this pull request unmergeable. Please resolve the merge conflicts.

@Noratrieb
Copy link
Member Author

no more hashmaps experiment

@Noratrieb Noratrieb closed this Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-perf Status: Waiting on a perf run to be completed. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants