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

Specialize ToString for Symbol #103656

Merged
merged 1 commit into from
Oct 29, 2022
Merged

Conversation

camsteffen
Copy link
Contributor

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented Oct 27, 2022

r? @estebank

(rustbot has picked a reviewer for you, use r? to override)

@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 Oct 27, 2022
@camsteffen
Copy link
Contributor Author

A simple local bench of sym::Display.to_string() shows a consistent change from 80ns/iter to 71ns/iter.

// takes advantage of `str::to_string` specialization
impl ToString for Symbol {
fn to_string(&self) -> String {
return self.as_str().to_string();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return self.as_str().to_string();
self.as_str().to_string()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to take a mental break after switching from Python.

@compiler-errors
Copy link
Member

@bors try @rust-timer queue

(though likely to show no results, since I guess heavy usage of Symbol::to_string happens on diagnostics paths only)

@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 Oct 28, 2022
@bors
Copy link
Contributor

bors commented Oct 28, 2022

⌛ Trying commit 382628149d3a76ade854d5cf3aaa087aeb675e79 with merge 6cdae94b58bcfb1ada8d169f8a6a36a73e68e77b...

@bors
Copy link
Contributor

bors commented Oct 28, 2022

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

@rust-timer
Copy link
Collaborator

Queued 6cdae94b58bcfb1ada8d169f8a6a36a73e68e77b with parent 126dbdc, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6cdae94b58bcfb1ada8d169f8a6a36a73e68e77b): 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-review -S-waiting-on-perf -perf-regression

Instruction count

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

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 Oct 28, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6cdae94b58bcfb1ada8d169f8a6a36a73e68e77b): 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-review -S-waiting-on-perf -perf-regression

Instruction count

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

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.

@compiler-errors
Copy link
Member

Hm, maybe this PR is not worth the added impl? Unless @camsteffen has something in mind that benefits from this speed boost.

@camsteffen
Copy link
Contributor Author

I could go either way. On one hand Symbol is very widely used and this is a low-cost common-sense optimization. On the other hand this probably won't make anyone's life better.

@compiler-errors
Copy link
Member

I guess it doesn't hurt anything.

r? @compiler-errors @bors r+

@bors
Copy link
Contributor

bors commented Oct 28, 2022

📌 Commit 382628149d3a76ade854d5cf3aaa087aeb675e79 has been approved by compiler-errors

It is now in the queue for this repository.

@rustbot rustbot assigned compiler-errors and unassigned estebank Oct 28, 2022
@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 Oct 28, 2022
@camsteffen
Copy link
Contributor Author

@bors r=compiler-errors

Removed the needless return

@bors
Copy link
Contributor

bors commented Oct 28, 2022

📌 Commit 298253a has been approved by compiler-errors

It is now in the queue for this repository.

@compiler-errors
Copy link
Member

Thanks, forgot that hadn't gotten applied.

@camsteffen
Copy link
Contributor Author

@bors rollup

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 29, 2022
…piler-errors

Specialize ToString for Symbol
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 29, 2022
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#102961 (Make `CStr::from_ptr` `const`.)
 - rust-lang#103342 (Add test for issue 98634)
 - rust-lang#103383 (Note scope of TAIT more accurately)
 - rust-lang#103656 (Specialize ToString for Symbol)
 - rust-lang#103663 (rustdoc: remove redundant CSS/DOM `div.search-container`)
 - rust-lang#103664 (rustdoc-json-types: Improve ItemSummary::path docs)
 - rust-lang#103704 (Add a test for TAIT used with impl/dyn Trait inside RPIT)

Failed merges:

 - rust-lang#103618 (Rename some `OwnerId` fields.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f41b1bf into rust-lang:master Oct 29, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 29, 2022
@camsteffen camsteffen deleted the symbol-to-string branch October 29, 2022 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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