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

Retry failed macro matching for diagnostics #103898

Merged
merged 7 commits into from
Nov 11, 2022
Merged

Conversation

Noratrieb
Copy link
Member

When a declarative macro fails to match, retry the matching to collect diagnostic info instead of collecting it on the fly in the hot path. Split out of #103439.

You made a bunch of changes to declarative macro matching, so
r? @nnethercote

This change should produce a few small perf wins: #103439 (comment)

This should allow us to collect detailed information without slowing
down the inital hot path.
This moves out the matching part of expansion into a new function. This
function will try to match the macro and return an error if it failed to
match. A tracker can be used to get more information about the matching.
For now, we only collect the small info for the `best_failure`, but
using this tracker, we can easily extend it in the future to track
things with more performance overhead.

We cannot retry cases where the macro failed with a parser error that
was emitted already, as that would cause us to emit the same error to
the user twice.
@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 Nov 2, 2022
These were useful while debugging, so I'll leave them here.
@compiler-errors
Copy link
Member

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

bors commented Nov 2, 2022

⌛ Trying commit 1e21b3c with merge 77c0eb6b819434c3e06697b4741abf4b7aa968fb...

@bors
Copy link
Contributor

bors commented Nov 2, 2022

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

@rust-timer
Copy link
Collaborator

Queued 77c0eb6b819434c3e06697b4741abf4b7aa968fb with parent edf0182, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (77c0eb6b819434c3e06697b4741abf4b7aa968fb): comparison URL.

Overall result: ✅ improvements - 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 is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-1.3%, -0.3%] 11
Improvements ✅
(secondary)
-2.1% [-2.8%, -1.6%] 6
All ❌✅ (primary) -0.8% [-1.3%, -0.3%] 11

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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 Nov 3, 2022
@nnethercote
Copy link
Contributor

nnethercote commented Nov 4, 2022

I don't like how this adds complexity to some code that is already very complex. But error messages for declarative macros are pretty bad, so improvement there is welcome. And the html5ever perf wins are nice. So overall I am inclined to accept this once the requested changes are made and questions answered.

@Noratrieb
Copy link
Member Author

@nnethercote in case you've missed the commit :)

@nnethercote
Copy link
Contributor

Yes, sorry, I missed it.

@bors r+

@bors
Copy link
Contributor

bors commented Nov 11, 2022

📌 Commit ebfa2ab has been approved by nnethercote

It is now in the queue for this repository.

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

bors commented Nov 11, 2022

⌛ Testing commit ebfa2ab with merge b7b7f27...

@bors
Copy link
Contributor

bors commented Nov 11, 2022

☀️ Test successful - checks-actions
Approved by: nnethercote
Pushing b7b7f27 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 11, 2022
@bors bors merged commit b7b7f27 into rust-lang:master Nov 11, 2022
@rustbot rustbot added this to the 1.67.0 milestone Nov 11, 2022
@Noratrieb Noratrieb deleted the match-macro branch November 11, 2022 08:47
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b7b7f27): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-1.3%, -0.3%] 11
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-1.3%, -0.3%] 11

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.

Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
Retry failed macro matching for diagnostics

When a declarative macro fails to match, retry the matching to collect diagnostic info instead of collecting it on the fly in the hot path. Split out of rust-lang#103439.

You made a bunch of changes to declarative macro matching, so
r? `@nnethercote`

This change should produce a few small perf wins: rust-lang#103439 (comment)
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. 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