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

Introduce RawVec::reserve_for_push. #91352

Merged
merged 1 commit into from Nov 30, 2021

Conversation

nnethercote
Copy link
Contributor

If Vec::push's capacity check fails it calls RawVec::reserve, which
then also does a capacity check.

This commit introduces reserve_for_push which skips the redundant
capacity check, for some slight compile time speed-ups.

I tried lots of minor variations on this, e.g. different inlining
attributes. This was the best one I could find.

r? @ghost

@nnethercote
Copy link
Contributor Author

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

bors commented Nov 29, 2021

⌛ Trying commit 0b2cf79825ef392a8afb6f97c4520ed96d839f9b with merge 7ab15d61caf7de62a33d9209692eefb792143ae8...

@bors
Copy link
Contributor

bors commented Nov 29, 2021

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

@rust-timer
Copy link
Collaborator

Queued 7ab15d61caf7de62a33d9209692eefb792143ae8 with parent 44723c5, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7ab15d61caf7de62a33d9209692eefb792143ae8): comparison url.

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

  • Large improvement in instruction counts (up to -3.0% on incr-patched: println builds of webrender-wrench)
  • Small regression in instruction counts (up to 0.4% on incr-patched: dummy fn builds of unify-linearly)

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. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 29, 2021
@nnethercote
Copy link
Contributor Author

Perf results look good, and the instruction count improvements are mostly among the real-world benchmarks, which is nice.

r? @dtolnay

If `Vec::push`'s capacity check fails it calls `RawVec::reserve`, which
then also does a capacity check.

This commit introduces `reserve_for_push` which skips the redundant
capacity check, for some slight compile time speed-ups.

I tried lots of minor variations on this, e.g. different inlining
attributes. This was the best one I could find.
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@dtolnay
Copy link
Member

dtolnay commented Nov 29, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Nov 29, 2021

📌 Commit 6a83352 has been approved by dtolnay

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

bors commented Nov 30, 2021

⌛ Testing commit 6a83352 with merge 207c80f...

@bors
Copy link
Contributor

bors commented Nov 30, 2021

☀️ Test successful - checks-actions
Approved by: dtolnay
Pushing 207c80f to master...

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

Finished benchmarking commit (207c80f): comparison url.

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

  • Large improvement in instruction counts (up to -3.0% on incr-patched: println builds of webrender-wrench)
  • Small regression in instruction counts (up to 0.4% on incr-patched: println builds of style-servo)

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

@nnethercote
Copy link
Contributor Author

@rustbot label: +perf-regression-triaged

Because (a) the instruction counts improvement significantly outweigh the regressions in size, and (b) the improvements are all in real-world benchmarks, while the regressions are mostly in artificial benchmarks.

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Nov 30, 2021
@nnethercote nnethercote deleted the RawVec-reserve_for_push branch November 30, 2021 20:17
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants