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

remove some indirection from proc_macro_server #90876

Closed
wants to merge 1 commit into from

Conversation

mystor
Copy link
Contributor

@mystor mystor commented Nov 13, 2021

This is a theoretical fix for the performance regression from #87264, based on wild guessing about what may have caused the regression. The patch reduces indirections when getting a ParseSess and debug-formatting Spans in the proc macro server.

@rust-highfive
Copy link
Collaborator

r? @oli-obk

(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 13, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Nov 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 Nov 13, 2021
@bors
Copy link
Contributor

bors commented Nov 13, 2021

⌛ Trying commit 943798401d23b0dfedfa3705aa6744bf5ec6cf1f with merge 16d626fda14734fe3545bd55d283c5dd2973d0e8...

@bors
Copy link
Contributor

bors commented Nov 13, 2021

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

@rust-timer
Copy link
Collaborator

Queued 16d626fda14734fe3545bd55d283c5dd2973d0e8 with parent 1b12d01, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (16d626fda14734fe3545bd55d283c5dd2973d0e8): comparison url.

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

  • Large improvement in instruction counts (up to -3.8% on incr-unchanged builds of deep-vector)
  • Moderate regression in instruction counts (up to 0.5% on incr-unchanged builds of style-servo)

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 13, 2021
@mystor
Copy link
Contributor Author

mystor commented Nov 14, 2021

Well, that appears to have changed perf counts, but for a completely different test than the regression in #87264 (comment)...

Comment on lines 781 to 778
if self.ecx.ecfg.span_debug {
if self.span_debug {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should cause any perf change, can you test it in isolation?

Comment on lines 380 to 382
fn sess(&self) -> &ParseSess {
self.ecx.parse_sess()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we'll get the same perf if parse_sess and sess are both #[inline]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps. My reasoning here was just that it would remove some pointer chasing, as what was previously 1 indirect read (self.sess) is now 2 (self.ecx.sess, parse_sess is an inline field of Session, so doesn't require an additional pointer chase). If the functions are not being inlined, though, that's more likely to be the cause of the perf loss.

I'll push another version where I just #[inline] the two functions.

@mystor
Copy link
Contributor Author

mystor commented Nov 17, 2021

I'm guessing I don't have the permissions to ask bors to run perf tests, but I suppose it's worth a try :-)

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Insufficient permissions to issue commands to rust-timer.

@bors
Copy link
Contributor

bors commented Nov 17, 2021

@mystor: 🔑 Insufficient privileges: not in try users

@oli-obk
Copy link
Contributor

oli-obk commented Nov 17, 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 17, 2021
@bors
Copy link
Contributor

bors commented Nov 17, 2021

⌛ Trying commit e168f91 with merge 412e53deb3152c35a44186f969f8334da38f3d35...

@bors
Copy link
Contributor

bors commented Nov 17, 2021

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

@rust-timer
Copy link
Collaborator

Queued 412e53deb3152c35a44186f969f8334da38f3d35 with parent 41301c3, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (412e53deb3152c35a44186f969f8334da38f3d35): comparison url.

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

  • Small improvement in instruction counts (up to -1.0% on incr-full builds of inflate)
  • Small regression in instruction counts (up to 0.5% on incr-unchanged builds of helloworld)

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 removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 17, 2021
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 18, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 5, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 30, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Feb 24, 2022

do you want to try something else here or should we just close? Doesn't seem like there is anything obvious

@mystor
Copy link
Contributor Author

mystor commented Feb 25, 2022

Yeah I don't see anything obvious and don't have a ton of time to continue investigating right now, so closing the bug seems reasonable to me.

@oli-obk oli-obk closed this Feb 25, 2022
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-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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants