Skip to content

Mark String::clone as inline-able #88916

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

Closed

Conversation

notriddle
Copy link
Contributor

It calls Vec::clone and performs a newtype-wrap around it, so it should be trivial enough that it doesn't cause major size regressions. It also fixes #88905

It calls `Vec::clone` and performs a newtype-wrap around it,
so it should be trivial enough that it doesn't cause major size
regressions. It also fixes rust-lang#88905
@rust-highfive
Copy link
Contributor

r? @dtolnay

(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 Sep 13, 2021
@camelid
Copy link
Member

camelid commented Sep 13, 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 Sep 13, 2021
@bors
Copy link
Collaborator

bors commented Sep 13, 2021

⌛ Trying commit e32f90c with merge 4997354d85d9c0ea35ae9df9300fa1db9de4997b...

@camelid camelid added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 13, 2021
@bors
Copy link
Collaborator

bors commented Sep 13, 2021

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

@rust-timer
Copy link
Collaborator

Queued 4997354d85d9c0ea35ae9df9300fa1db9de4997b with parent 9bb77da, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4997354d85d9c0ea35ae9df9300fa1db9de4997b): comparison url.

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

  • Moderate improvement in instruction counts (up to -0.8% on incr-patched: b9b3e592dd cherry picked builds of style-servo)
  • Small regression in instruction counts (up to 2.1% on incr-patched: println builds of regression-31157)

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 Sep 14, 2021
@camelid
Copy link
Member

camelid commented Sep 14, 2021

Hmm, seems like the results are quite mixed. It could be worth doing another perf run to see if the results are spurious, but I'll let T-libs decide.

@the8472
Copy link
Member

the8472 commented Sep 14, 2021

Note that LTO does inline this, it'll only benefit non-LTO builds.

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.

I am not convinced that it is worth making this change. Is there a common idiom that leads to strings getting cloned and never used? If this is minimized from real world code then we can evaluate vs the costs of inline, but I am having trouble seeing how this would come up in a hot path in practice.

@dtolnay dtolnay 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 Oct 3, 2021
@dtolnay dtolnay closed this Oct 10, 2021
@notriddle notriddle deleted the notriddle/inline-string-clone branch October 10, 2021 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

String cloning is not optimized the same way as String construction
8 participants