Repository navigation
Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
cc @the8472, this looks good to me? |
|
Hrm yeah, should be fine. Can you run the |
|
Writing a single |
|
A nice thing about this (compared to writing a nul) is that a Hasher that only cares about performance can override write_length_prefix as a noop. That said, I don't feel that strongly about it. |
This comment has been minimized.
This comment has been minimized.
|
Is there some reason why we hash component-by-component, rather than calling |
|
We need to uphold |
|
There's something wacky going on with these test failures. I can get the same failure by making any substantial change to I can also make the failure disappear by passing So I think the stage1 compiler is somehow generating crate output that then confuses the stage2 compiler. Theoretically that shouldn't happen, but perhaps details of Path hashing are somehow influencing the stage1 compiler's output in ways that they shouldn't be. (Note that the stage1 compiler is itself built by the stage0 compiler, and is thus linked against the stage0 stdlib, which doesn't include the hashing changes. That shouldn't matter, but perhaps it is mattering somehow.) |
|
I am happy with this change but we really do need to figure out bootstrap. |
|
Testing the standard library depends on the sysroot containing identical rlibs to the rlibs that |
|
Compiler-side blockage should now have been resolved by #164458. |
|
Great! @ultrabear could you rebase? |
Yep! just saw this |
fc32b79 to
51094a2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I rebased against my forks latest main... going to do some surgery |
51094a2 to
82661bf
Compare
This comment has been minimized.
This comment has been minimized.
|
@the8472 I tried to get the benches going using DetailsWas I perhaps using the wrong command? not sure this is expected behavior either way |
|
@ultrabear it looks like the bench problem has been fixed in #165762. Rebase and try again? |
82661bf to
d2510ec
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Ran: This PR d2510ec: benchmarks:
path::bench_hash_path_long 56.91ns/iter +/- 1.09
path::bench_hash_path_short 7.46ns/iter +/- 1.01
path::bench_path_cmp_fast_path_buf_sort 20416.80ns/iter +/- 463.60
path::bench_path_cmp_fast_path_long 865.84ns/iter +/- 16.92
path::bench_path_cmp_fast_path_short 571.66ns/iter +/- 10.08
path::bench_path_components_iter 64.77ns/iter +/- 0.33
path::bench_path_file_name 26.96ns/iter +/- 0.32
path::bench_path_hashset 160.42ns/iter +/- 4.17
path::bench_path_hashset_miss 82.13ns/iter +/- 6.62main c884ecf: benchmarks:
path::bench_hash_path_long 42.44ns/iter +/- 2.35
path::bench_hash_path_short 8.08ns/iter +/- 0.17
path::bench_path_cmp_fast_path_buf_sort 20548.15ns/iter +/- 169.25
path::bench_path_cmp_fast_path_long 867.32ns/iter +/- 24.25
path::bench_path_cmp_fast_path_short 570.27ns/iter +/- 7.70
path::bench_path_components_iter 65.02ns/iter +/- 0.37
path::bench_path_file_name 27.01ns/iter +/- 0.50
path::bench_path_hashset 104.11ns/iter +/- 1.42
path::bench_path_hashset_miss 48.83ns/iter +/- 4.62Noise: Im running on a laptop with a standard linux DE creating between 1-5% idle cpu, cpu governor was set to performance profile and plugged in |
|
the hashset bench appears to have been blown to smithereens, i did a rerun to confirm and got similar numbers |
|
Oof, but yeah that benchmark was written to exercise exactly this code and it's now doing significantly more work. I'm not sure if that's fixable. Let's see how this affects cargo and stuff @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Make `impl Hash for Path` not use custom intermediate hash cycle
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (f7cf8d5): comparison URL. Overall result: no relevant changes - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (primary 4.1%, secondary 0.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -1.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 458.8s -> 456.908s (-0.41%) |
View all comments
This is NOT A FIX for #164348 but was inspired by it. The previous implementation of
impl Hash for Pathused a low quality hashing core:this was done independently of the Hasher implementation and results in an inversion of expectations, an implementer of Hash should supply its meaningful entropy,
and a Hasher implementation should decide how to hash that entropy.
The proposed fix: use
h.write_length_prefix(to_hash.len())instead of (pseudocode)chunk_bits.update(to_hash.len())with a finalh.write_usize(chunk_bits).On typical "fast" hashers write_length_prefix will go to an optimized core that can be as few instructions as the original low quality hashing core in
impl Hash for PathOR chose to be more secure (as is typically the case, see rustc-hash for example)On typical "cryptographic" hashers the performance difference is not meaningful, as the prior implementation of
impl Hash for Pathwould simply feed poorly hashed data to the hasher and thus make it impossible for a cryptographic Hasher function to meaningfully work on Path in the first place. This change allows that usecase to exist.