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

Implement StableHasher::write_u128 via write_u64 #110410

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Apr 16, 2023

In #110367 (comment) the cachegrind diffs indicate that nearly all the regression is from this:

22,892,558  ???:<rustc_data_structures::sip128::SipHasher128>::slice_write_process_buffer
-9,502,262  ???:<rustc_data_structures::sip128::SipHasher128>::short_write_process_buffer::<8>

Which happens because the diff for that perf run swaps a Hash::hash of a u64 to a u128. But slice_write_process_buffer is a #[cold] function, and is for handling hashes of arbitrary-length byte arrays.

Using the much more optimizer-friendly u64 path twice to hash a u128 provides a nice perf boost in some benchmarks.

@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 Apr 16, 2023
@saethlin
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 16, 2023
@bors
Copy link
Contributor

bors commented Apr 16, 2023

⌛ Trying commit ad8d304 with merge 29bb036a6ff39a9cb5841c4f2affd349246adbd9...

@bors
Copy link
Contributor

bors commented Apr 16, 2023

☀️ Try build successful - checks-actions
Build commit: 29bb036a6ff39a9cb5841c4f2affd349246adbd9 (29bb036a6ff39a9cb5841c4f2affd349246adbd9)

1 similar comment
@bors
Copy link
Contributor

bors commented Apr 16, 2023

☀️ Try build successful - checks-actions
Build commit: 29bb036a6ff39a9cb5841c4f2affd349246adbd9 (29bb036a6ff39a9cb5841c4f2affd349246adbd9)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (29bb036a6ff39a9cb5841c4f2affd349246adbd9): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.4%, -0.3%] 3
Improvements ✅
(secondary)
-0.6% [-0.9%, -0.5%] 14
All ❌✅ (primary) -0.3% [-0.4%, -0.3%] 3

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 16, 2023
@saethlin saethlin marked this pull request as ready for review April 16, 2023 22:22
@oli-obk
Copy link
Contributor

oli-obk commented Apr 16, 2023

r? @oli-obk @bors r+

@bors
Copy link
Contributor

bors commented Apr 16, 2023

📌 Commit ad8d304 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 16, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 17, 2023
Remove some suspicious cast truncations

These truncations were added a long time ago, and as best I can tell without a perf justification. And with rust-lang#110410 it has become perf-neutral to not truncate anymore. We worked hard for all these bits, let's use them.
@bors
Copy link
Contributor

bors commented Apr 18, 2023

⌛ Testing commit ad8d304 with merge 3860251...

@bors
Copy link
Contributor

bors commented Apr 18, 2023

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 3860251 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 18, 2023
@bors bors merged commit 3860251 into rust-lang:master Apr 18, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 18, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3860251): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-2.8%, -0.2%] 13
Improvements ✅
(secondary)
-1.9% [-7.5%, -0.2%] 24
All ❌✅ (primary) -0.7% [-2.8%, -0.2%] 13

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.5% [1.3%, 1.7%] 3
Regressions ❌
(secondary)
3.2% [3.1%, 3.4%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.5% [1.3%, 1.7%] 3

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.8%, -2.0%] 4
All ❌✅ (primary) - - 0

@lqd
Copy link
Member

lqd commented Apr 18, 2023

Note for weekly triage: cranelift-codegen and keccak are currently very noisy unfortunately, e.g.

image

RalfJung pushed a commit to RalfJung/miri that referenced this pull request Apr 22, 2023
Remove some suspicious cast truncations

These truncations were added a long time ago, and as best I can tell without a perf justification. And with rust-lang/rust#110410 it has become perf-neutral to not truncate anymore. We worked hard for all these bits, let's use them.
@saethlin saethlin deleted the hash-u128-as-u64s branch April 28, 2023 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants