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

WIP: vendor rustc-hash and override str/length_prefix methods #120078

Closed

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Jan 18, 2024

Locally avoiding length and str sentinel hashing adds 2,611,200 cases of hashes with just one add_to_hash call (out of roughly 43,063,296 total cases). Unclear what kind of effect this will have on runtime performance at this time, but seems like it's worth trying!

cc #56308

Locally avoiding length and str sentinel hashing adds 2,611,200 cases of
hashes with just one add_to_hash call (out of roughly 43,063,296 total
cases). Unclear what kind of effect this will have on runtime
performance at this time, but seems like it's worth trying!
@rustbot
Copy link
Collaborator

rustbot commented Jan 18, 2024

@Mark-Simulacrum: no appropriate reviewer found, use r? to override

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 18, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jan 18, 2024

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@Mark-Simulacrum
Copy link
Member Author

@bors try @rust-timer queue

cc #96762 -- probably worthwhile data for that tracking issue, regardless of whether positive or negative.

@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 Jan 18, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 18, 2024
WIP: vendor rustc-hash and override str/length_prefix methods

Locally avoiding length and str sentinel hashing adds 2,611,200 cases of hashes with just one add_to_hash call (out of roughly 43,063,296 total cases). Unclear what kind of effect this will have on runtime performance at this time, but seems like it's worth trying!
@bors
Copy link
Contributor

bors commented Jan 18, 2024

⌛ Trying commit c9e83b6 with merge 5f68de8...

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 18, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 18, 2024
@rust-log-analyzer

This comment has been minimized.

@Mark-Simulacrum
Copy link
Member Author

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 18, 2024
WIP: vendor rustc-hash and override str/length_prefix methods

Locally avoiding length and str sentinel hashing adds 2,611,200 cases of hashes with just one add_to_hash call (out of roughly 43,063,296 total cases). Unclear what kind of effect this will have on runtime performance at this time, but seems like it's worth trying!

cc rust-lang#56308
@bors
Copy link
Contributor

bors commented Jan 18, 2024

⌛ Trying commit b24c62d with merge 256f15b...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 18, 2024

☀️ Try build successful - checks-actions
Build commit: 256f15b (256f15b530c3f5b8e4ef8e236d07432bdda9e3fc)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (256f15b): comparison URL.

Overall result: ❌ regressions - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@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)
5.2% [1.5%, 9.9%] 13
Regressions ❌
(secondary)
14.3% [0.5%, 25.8%] 15
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 5.2% [1.5%, 9.9%] 13

Max RSS (memory usage)

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

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)
5.9% [1.8%, 12.5%] 13
Regressions ❌
(secondary)
16.0% [2.1%, 30.7%] 16
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 5.9% [1.8%, 12.5%] 13

Binary size

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

Bootstrap: 663.454s -> 664.246s (0.12%)
Artifact size: 308.30 MiB -> 308.30 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 18, 2024
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_58a9cf6e-7d5b-44ad-bb9f-7b1a2addf92c
GITHUB_EVENT_NAME=pull_request
GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=skip-hashers
GITHUB_JOB=pr
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_58a9cf6e-7d5b-44ad-bb9f-7b1a2addf92c
GITHUB_REF=refs/pull/120078/merge
GITHUB_REF_NAME=120078/merge
GITHUB_REF_PROTECTED=false
---
* Read errors: 0
* Files with copyright information: 179930 / 179937
* Files with license information: 179929 / 179937

Unfortunately, your project is not compliant with version 3.0 of the REUSE Specification :-(
  network time: Sat, 20 Jan 2024 01:20:16 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@Mark-Simulacrum
Copy link
Member Author

@bors try @rust-timer queue

It looks like we have pretty terrible hash quality for strings -- looking locally, e.g., libcore has ~70k Symbols so roughly speaking the ~17 lower bits of the hash function are getting used. For simplicity if we take the lower 16 bits we can see there are 41.7k unique values when hashing in 0xFF and 39.9k unique values when just hashing the bytes of the string. My guess is that final 0xFF hash helps smear/distribute short tails which otherwise dominate the hash's value too much.

For now I'm going to re-run with 0xFF added back in but I think we should consider whether hashing long byte strings is actually working well enough -- and maybe a different hash function would be better for maps where we have non (roughly) u32 integers as keys. The two benchmarks that regressed here have similarly not-great performance for the hash function, which is why they're regressing so much.

@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 Jan 20, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 20, 2024
WIP: vendor rustc-hash and override str/length_prefix methods

Locally avoiding length and str sentinel hashing adds 2,611,200 cases of hashes with just one add_to_hash call (out of roughly 43,063,296 total cases). Unclear what kind of effect this will have on runtime performance at this time, but seems like it's worth trying!

cc rust-lang#56308
@bors
Copy link
Contributor

bors commented Jan 20, 2024

⌛ Trying commit 6ca3c44 with merge f7f7717...

@bors
Copy link
Contributor

bors commented Jan 20, 2024

☀️ Try build successful - checks-actions
Build commit: f7f7717 (f7f7717d4e9135238fdf8784d6487d1380c6d91d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f7f7717): comparison URL.

Overall result: no relevant changes - 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 benchmark run did not return any relevant results for this metric.

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.6% [1.6%, 1.6%] 1
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.6% [-4.6%, -4.6%] 1
All ❌✅ (primary) 1.6% [1.6%, 1.6%] 1

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)
1.5% [1.5%, 1.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.2% [-1.2%, -1.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [-1.2%, 1.5%] 2

Binary size

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.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [0.5%, 0.5%] 1

Bootstrap: 663.584s -> 666.051s (0.37%)
Artifact size: 308.31 MiB -> 308.33 MiB (0.01%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Jan 20, 2024
@Mark-Simulacrum
Copy link
Member Author

Seems like this didn't really pan out directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants