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

Optimize Eq and Hash for Path/PathBuf #90596

Merged
merged 5 commits into from
Nov 14, 2021
Merged

Conversation

the8472
Copy link
Member

@the8472 the8472 commented Nov 5, 2021

# new

test path::tests::bench_hash_path_long                            ... bench:          86 ns/iter (+/- 1)
test path::tests::bench_hash_path_short                           ... bench:          13 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:         197 ns/iter (+/- 6)
test path::tests::bench_path_hashset_miss                         ... bench:          94 ns/iter (+/- 4)

# old

test path::tests::bench_hash_path_long                            ... bench:         192 ns/iter (+/- 2)
test path::tests::bench_hash_path_short                           ... bench:          33 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:       1,121 ns/iter (+/- 24)
test path::tests::bench_path_hashset_miss                         ... bench:         273 ns/iter (+/- 6)

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 5, 2021
@the8472 the8472 added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Nov 5, 2021
@rust-log-analyzer

This comment has been minimized.

library/std/src/path.rs Outdated Show resolved Hide resolved
@the8472
Copy link
Member Author

the8472 commented Nov 5, 2021

@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 Nov 5, 2021
@bors
Copy link
Contributor

bors commented Nov 5, 2021

⌛ Trying commit c3a8b341d5d494891381ed81db3527b0362549c4 with merge eb2afd0294bbfeb7aa214aeacedd15e1c1351dad...

@bors
Copy link
Contributor

bors commented Nov 5, 2021

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

@rust-timer
Copy link
Collaborator

Queued eb2afd0294bbfeb7aa214aeacedd15e1c1351dad with parent d22dd65, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (eb2afd0294bbfeb7aa214aeacedd15e1c1351dad): comparison url.

Summary: This change led to large relevant mixed results 🤷 in compiler performance.

  • Large improvement in instruction counts (up to -2.3% on incr-unchanged builds of helloworld)
  • Large regression in instruction counts (up to 4.8% on incr-patched: println builds of webrender-wrench)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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 led 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-review -S-waiting-on-perf +perf-regression

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 5, 2021
@the8472
Copy link
Member Author

the8472 commented Nov 5, 2021

Almost entirely improvements except for webrender-wrench - opt - incr-patched: println which spends more time in llvm. I guess that it makes use of a lot of paths and has to spend more time to optimize it, likely trading compile time for runtime in that case. The patched file does make use of PathBuf.

@joshtriplett
Copy link
Member

This seems like a reasonable set of performance numbers to me; it's paying compile time to get more runtime performance.

library/std/src/path.rs Outdated Show resolved Hide resolved
library/std/src/path.rs Show resolved Hide resolved
library/std/src/path.rs Show resolved Hide resolved
@Mark-Simulacrum Mark-Simulacrum 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 Nov 8, 2021
@rust-log-analyzer

This comment has been minimized.

@the8472 the8472 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 8, 2021
@Mark-Simulacrum
Copy link
Member

OK, this looks good to me. I think the commit history can be cleaned up a little -- 8 commits seems a little too many :)

But otherwise r=me.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 9, 2021
@bors
Copy link
Contributor

bors commented Nov 10, 2021

⌛ Testing commit a6e0aa2 with merge 2ec3ee22b5808ab9a312c46fff596a7789f58752...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 10, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 10, 2021
@the8472 the8472 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 Nov 10, 2021
@the8472
Copy link
Member Author

the8472 commented Nov 10, 2021

Apparently the drive prefixes are the only thing where we do case-insensitive comparison on paths. 😮‍💨
Not sure yet how to solve that efficiently.

@ChrisDenton
Copy link
Member

ChrisDenton commented Nov 10, 2021

Apparently the drive prefixes are the only thing where we do case-insensitive comparison on paths.

They are the only place that are guaranteed to be ASCII case-insensitive. Other parts of the path could be case-sensitive.

@the8472 the8472 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 11, 2021
…f trying to hash the raw bytes

This should have 0 performance overhead on unix since Prefix is always None.
@the8472
Copy link
Member Author

the8472 commented Nov 11, 2021

@Mark-Simulacrum ready for another review, the latest commit should fix the windows failure.

@Mark-Simulacrum
Copy link
Member

@bors r=Mark-Simulacrum rollup=never

@bors
Copy link
Contributor

bors commented Nov 14, 2021

📌 Commit c1ea7bd has been approved by Mark-Simulacrum

@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 Nov 14, 2021
@bors
Copy link
Contributor

bors commented Nov 14, 2021

⌛ Testing commit c1ea7bd with merge c8e9497...

@bors
Copy link
Contributor

bors commented Nov 14, 2021

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing c8e9497 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 14, 2021
@bors bors merged commit c8e9497 into rust-lang:master Nov 14, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 14, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c8e9497): comparison url.

Summary: This change led to very large relevant mixed results 🤷 in compiler performance.

  • Very large improvement in instruction counts (up to -6.0% on incr-unchanged builds of coercions)
  • Very large regression in instruction counts (up to 12.9% on incr-unchanged builds of tuple-stress)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

@the8472
Copy link
Member Author

the8472 commented Nov 15, 2021

Comparing the call graphs of perf profiles before and after this PR for tuple-stress shows a big difference in the callees of rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::DefId, &rustc_middle::mir::Body>.

Before the PR:

  • <rustc_query_impl::on_disk_cache::OnDiskCache>::try_load_query_result::<&rustc_middle::mir::Body>
    (7.8e9 instructions)

After the PR:

  • <rustc_query_impl::on_disk_cache::OnDiskCache>::try_load_query_result::<&rustc_middle::mir::Body>
    (7.8e9 instructions)
  • rustc_query_system::query::plumbing::incremental_verify_ich::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::DefId, &rustc_middle::mir::Body>
    (6.3e9 instructions)

In other words changes to hashing triggered probabilistic incremental verification (#90361)

@the8472 the8472 added the perf-regression-triaged The performance regression has been triaged. label Nov 15, 2021
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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants