Repository navigation
perf: avoid allocating HashSet in is_distinct check on small SwitchInts - #164969
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
perf: avoid allocating HashSet in is_distinct check on small SwitchInts
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (46f8fa0): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @bors rollup=iffy rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.2%, secondary 0.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.1%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 488.092s -> 488.091s (-0.00%) |
|
Otherwise, the result is positive, but it's sadly not super visible. This code is only used in opt builds, because it's called by It's a bit unfortunate that for opt builds, almost everything is overshadowed by time spent in LLVM, so we can't easily measure small changes in there, it will end up below significance threshold. When I run cachegrind diff on diesel, which is a benchmark that calls this function a lot (500k times), the result is pretty much exactly right: -26,136,452 (100.0%) PROGRAM TOTALS
Ir________________________ function:file
> -9,129,848 (34.9%, 34.9%) <hashbrown::map::HashMap<&rustc_middle::mir::BasicBlock, (), rustc_hash::FxBuildHasher>>::insert:
-2,323,344 (8.9%) /cargo/registry/25cdd57fae9f0462/hashbrown-0.17.1/src/map.rs
-2,033,154 (7.8%) /cargo/registry/25cdd57fae9f0462/hashbrown-0.17.1/src/raw.rs
-1,160,760 (4.4%) /cargo/registry/25cdd57fae9f0462/hashbrown-0.17.1/src/control/tag.rs
-879,117 (3.4%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/../../stdarch/crates/core_arch/src/x86/sse2.rs
-580,380 (2.2%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/num/uint_macros.rs
-483,650 (1.9%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/ptr/mod.rs
-402,190 (1.5%) /cargo/registry/25cdd57fae9f0462/hashbrown-0.17.1/src/control/bitmask.rs
-388,136 (1.5%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/intrinsics/mod.rs
-293,838 (1.1%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/ptr/mut_ptr.rs
-290,190 (1.1%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/macros/mod.rs
-97,946 (0.4%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/num/nonzero.rs
-96,730 (0.4%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/ub_checks.rs
-96,730 (0.4%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/convert/num.rs
> -4,028,190 (15.4%, 50.3%) <hashbrown::raw::RawTable<(&rustc_middle::mir::BasicBlock, ())>>::reserve_rehash::<hashbrown::map::make_hasher<&rustc_middle::mir::BasicBlock, (), rustc_hash::FxBuildHasher>::{closure#0}>:
-2,579,455 (9.9%) /cargo/registry/25cdd57fae9f0462/hashbrown-0.17.1/src/raw.rs
-459,355 (1.8%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/num/uint_macros.rs
-318,015 (1.2%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/ptr/mod.rs
-212,010 (0.8%) /cargo/registry/25cdd57fae9f0462/hashbrown-0.17.1/src/alloc.rs
-141,340 (0.5%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/intrinsics/mod.rs
-141,340 (0.5%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/alloc/src/alloc.rs
-70,670 (0.3%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/cmp.rs
-35,335 (0.1%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/ub_checks.rs
-35,335 (0.1%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/ptr/mut_ptr.rs
-35,335 (0.1%) /cargo/registry/25cdd57fae9f0462/hashbrown-0.17.1/src/scopeguard.rs
> -1,972,066 (7.5%, 57.9%) _int_free:./malloc/./malloc/malloc.c
> -1,683,275 (6.4%, 64.3%) <core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::mir::BasicBlock>, <hashbrown::set::HashSet<&rustc_middle::mir::BasicBlock, rustc_hash::FxBuildHasher> as core::iter::traits::collect::Extend<&rustc_middle::mir::BasicBlock>>::extend<core::slice::iter::Iter<rustc_middle::mir::BasicBlock>>::{closure#0}> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::traits::iterator::Iterator::for_each::call<(&rustc_middle::mir::BasicBlock, ()), <hashbrown::map::HashMap<&rustc_middle::mir::BasicBlock, (), rustc_hash::FxBuildHasher> as core::iter::traits::collect::Extend<(&rustc_middle::mir::BasicBlock, ())>>::extend<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::mir::BasicBlock>, <hashbrown::set::HashSet<&rustc_middle::mir::BasicBlock, rustc_hash::FxBuildHasher> as core::iter::traits::collect::Extend<&rustc_middle::mir::BasicBlock>>::extend<core::slice::iter::Iter<rustc_middle::mir::BasicBlock>>::{closure#0}>>::{closure#0}>::{closure#0}>:
-598,930 (2.3%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/slice/iter/macros.rs
-424,020 (1.6%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/iter/adapters/map.rs
-290,190 (1.1%) /cargo/registry/25cdd57fae9f0462/hashbrown-0.17.1/src/map.rs
-193,460 (0.7%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/num/uint_macros.rs
-141,340 (0.5%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/ptr/const_ptr.rs
-35,335 (0.1%) /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/core/src/ptr/non_null.rs
... |
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@bors r+ |
…r=tmiasko perf: avoid allocating HashSet in is_distinct check on small SwitchInts
|
As panstromek mentioned, include-blob perf is noise. (The diesel result looks good tho) |
|
I should say the cachegrind diff is from local |
…uwer Rollup of 5 perf-sensitive pull requests Successful merges: - #163525 (Move lang item collection to the resolver) - #164234 (New solver opts for `diesel` (part 2)) - #164726 (perf: emit field names as a concatenated string in derive(Debug) for structs) - #164953 (Avoid stdlib's `impl Hash for Discriminant` for stable hashing) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts)
…r=tmiasko perf: avoid allocating HashSet in is_distinct check on small SwitchInts
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…r=tmiasko perf: avoid allocating HashSet in is_distinct check on small SwitchInts
…uwer Rollup of 23 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #165123 (Temporarily drop macos-26 jobs) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 23 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #165123 (Temporarily drop macos-26 jobs) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165123 (Temporarily drop macos-26 jobs) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
Rollup merge of #164969 - panstromek:is-distinct-fast-path, r=tmiasko perf: avoid allocating HashSet in is_distinct check on small SwitchInts
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#165032 (stdarch subtree update) - rust-lang/rust#165123 (Temporarily drop macos-26 jobs) - rust-lang/rust#165072 (Submodule update of rustc-perf) - rust-lang/rust#144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - rust-lang/rust#162342 (More stdarch regression tests) - rust-lang/rust#163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - rust-lang/rust#164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - rust-lang/rust#164916 (CI: rfl: move job forward to Linux v7.3) - rust-lang/rust#164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - rust-lang/rust#164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - rust-lang/rust#165083 (Gate `z` inline asm template modifier) - rust-lang/rust#165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - rust-lang/rust#161131 (Check associated const binding types) - rust-lang/rust#161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - rust-lang/rust#164315 (make powerpc `Complex` ABI GCC-compatible) - rust-lang/rust#164476 (Avoid ICE on None from prepare_vtable_segments) - rust-lang/rust#165003 (follow up for global-alloc-reentry test) - rust-lang/rust#165020 (Bless mir-opt panic-abort tests) - rust-lang/rust#165066 (skip max_repr_align in Layout::eq_abi) - rust-lang/rust#165080 (Syntactically allow C-variadics in parenthesized argument lists) - rust-lang/rust#165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - rust-lang/rust#165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#165032 (stdarch subtree update) - rust-lang/rust#165123 (Temporarily drop macos-26 jobs) - rust-lang/rust#165072 (Submodule update of rustc-perf) - rust-lang/rust#144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - rust-lang/rust#162342 (More stdarch regression tests) - rust-lang/rust#163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - rust-lang/rust#164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - rust-lang/rust#164916 (CI: rfl: move job forward to Linux v7.3) - rust-lang/rust#164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - rust-lang/rust#164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - rust-lang/rust#165083 (Gate `z` inline asm template modifier) - rust-lang/rust#165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - rust-lang/rust#161131 (Check associated const binding types) - rust-lang/rust#161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - rust-lang/rust#164315 (make powerpc `Complex` ABI GCC-compatible) - rust-lang/rust#164476 (Avoid ICE on None from prepare_vtable_segments) - rust-lang/rust#165003 (follow up for global-alloc-reentry test) - rust-lang/rust#165020 (Bless mir-opt panic-abort tests) - rust-lang/rust#165066 (skip max_repr_align in Layout::eq_abi) - rust-lang/rust#165080 (Syntactically allow C-variadics in parenthesized argument lists) - rust-lang/rust#165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - rust-lang/rust#165082 (Remove stability note from `rust_splat`)
No description provided.