Skip to content

remove visit_clobber and DummyAstNode #141430

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fee1-dead
Copy link
Member

used for one specific niche purpose, turns out we can just remove them and inline dummy values into callsites. this cleans them up.

@rustbot
Copy link
Collaborator

rustbot commented May 23, 2025

r? @oli-obk

rustbot has assigned @oli-obk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 May 23, 2025
@fmease
Copy link
Member

fmease commented May 23, 2025

FYI: Something similar was tried in an early version of PR #121829. Discussion: #121829 (comment), not sure if still relevant / relevant in general. I only skimmed your & the other PR.

@rust-log-analyzer

This comment has been minimized.

@fee1-dead fee1-dead force-pushed the push-nmzoprvtsvww branch from 219f808 to b84f556 Compare May 23, 2025 10:10
@fee1-dead
Copy link
Member Author

fee1-dead commented May 23, 2025

not sure if still relevant / relevant in general

seems irrelevant to me. There has been a year since the previous comment saying there could be additional uses of DummyAstNode but new use still has not appeared.

If we want to get a dummy of something why should we use a trait? just put it e.g. as an inherent method on P<Expr> would suffice too.

@rust-log-analyzer

This comment has been minimized.

@fee1-dead fee1-dead force-pushed the push-nmzoprvtsvww branch from b84f556 to c7ee736 Compare May 23, 2025 11:10
@rust-log-analyzer

This comment has been minimized.

@fee1-dead fee1-dead force-pushed the push-nmzoprvtsvww branch from c7ee736 to dbaf7ae Compare May 23, 2025 11:53
@rust-log-analyzer

This comment has been minimized.

@fee1-dead fee1-dead force-pushed the push-nmzoprvtsvww branch from dbaf7ae to 477d572 Compare May 23, 2025 12:04
@fee1-dead
Copy link
Member Author

🤦 Sorry for the spam. I really should stop being lazy and do more local testing before pushing.

@fmease
Copy link
Member

fmease commented May 23, 2025

Nah, stage2 tests are always a pain ^^'

@petrochenkov petrochenkov self-assigned this May 23, 2025
@petrochenkov
Copy link
Contributor

petrochenkov commented May 23, 2025

I don't think this is an improvement, invocation collector works with nodes generically, abstracting a number of small operations for every node, including clobbering.
trait InvocationCollectorNode is mostly used for that, but InvocationCollectorNode + DummyAstNode for some subset as well.
The current scheme also allows to do the clobbering only when strictly necessary (unlike this PR).
I'd rather prefer to keep things as is.

DummyAstNode and visit_clobber can be moved to expand.rs though.
Or even merged into InvocationCollectorNode with panic as the default implementation, but that would shift some errors from compile time to runtime.
Maybe some specific impls of DummyAstNode can also be removed now.

}
});
if let Some(expr) = opt_expr.take() {
*opt_expr = vis.filter_map_expr(expr)
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is good, it's simpler and visit_clobber is not used generically here.

tokens: None,
})
});
let expr = std::mem::replace(e, Expr::dummy());
Copy link
Contributor

Choose a reason for hiding this comment

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

This also looks better without visit_clobber.

@petrochenkov
Copy link
Contributor

r? @petrochenkov
@rustbot author

@rustbot
Copy link
Collaborator

rustbot commented May 23, 2025

Requested reviewer is already assigned to this pull request.

Please choose another assignee.

@rustbot rustbot 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 May 23, 2025
@fee1-dead
Copy link
Member Author

fee1-dead commented May 23, 2025

I don't think this is an improvement, invocation collector works with nodes generically, abstracting a number of small operations for every node, including clobbering.

As I said previously, I don't think having that generic behavior is necessary.

visit_node only needs the input type to implement DummyAstNode for clobbering because it takes in a &mut Node, when it doesn't have to. When it simply returns the new node created, clobbering is no longer needed.

The bridge from MutVisitor to InvocationCollectorNode is the clobbering. This PR makes the clobbering explicit and specific to each bridged type. InvocationCollectorNode does not need clobbering.

@petrochenkov
Copy link
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 23, 2025
bors added a commit that referenced this pull request May 23, 2025
remove `visit_clobber` and `DummyAstNode`

used for one specific niche purpose, turns out we can just remove them and inline dummy values into callsites. this cleans them up.
@bors
Copy link
Collaborator

bors commented May 23, 2025

⌛ Trying commit 477d572 with merge ec406cc...

@bors
Copy link
Collaborator

bors commented May 23, 2025

☀️ Try build successful - checks-actions
Build commit: ec406cc (ec406cc9a2d563186bb1b283394a034f064344ec)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ec406cc): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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.

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-perf +perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.3% [0.1%, 0.7%] 85
Regressions ❌
(secondary)
0.3% [0.1%, 0.9%] 36
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 2
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.1%] 7
All ❌✅ (primary) 0.2% [-0.2%, 0.7%] 87

Max RSS (memory usage)

Results (primary -0.6%, secondary -4.8%)

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)
1.9% [1.9%, 1.9%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.8% [-1.9%, -1.7%] 2
Improvements ✅
(secondary)
-4.8% [-4.8%, -4.8%] 1
All ❌✅ (primary) -0.6% [-1.9%, 1.9%] 3

Cycles

Results (primary 2.0%, secondary 2.1%)

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)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
2.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.0% [2.0%, 2.0%] 1

Binary size

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

Bootstrap: 776.992s -> 778.523s (0.20%)
Artifact size: 365.49 MiB -> 365.48 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 23, 2025
@petrochenkov
Copy link
Contributor

#141430 (comment)

Yeah, that's why the clobbering should be inside visit_node, and not done eagerly.

@fee1-dead
Copy link
Member Author

Yeah, that's why the clobbering should be inside visit_node, and not done eagerly.

ah, alright. I'll bring it back to rustc_expand, keeping the other cleanups then.

used for one specific niche purpose. move `DummyAstNode` to
`rustc_expand` as that is where it is used.
@fee1-dead fee1-dead force-pushed the push-nmzoprvtsvww branch from 477d572 to fd6eaac Compare May 24, 2025 07:21
@fee1-dead
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 24, 2025
@bors
Copy link
Collaborator

bors commented May 24, 2025

⌛ Trying commit fd6eaac with merge 25ef124...

bors added a commit that referenced this pull request May 24, 2025
remove `visit_clobber` and `DummyAstNode`

used for one specific niche purpose, turns out we can just remove them and inline dummy values into callsites. this cleans them up.
@bors
Copy link
Collaborator

bors commented May 24, 2025

☀️ Try build successful - checks-actions
Build commit: 25ef124 (25ef124a4c5f0a3a2acf384ca51af8c53d050940)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (25ef124): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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.

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-perf +perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 9
Improvements ✅
(primary)
-0.2% [-0.2%, -0.1%] 3
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.2%] 8
All ❌✅ (primary) -0.2% [-0.2%, -0.1%] 3

Max RSS (memory usage)

Results (primary 1.8%)

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)
1.8% [1.5%, 2.0%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.8% [1.5%, 2.0%] 2

Cycles

Results (primary 2.3%)

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)
2.3% [2.3%, 2.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.3% [2.3%, 2.3%] 1

Binary size

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

Bootstrap: 777.008s -> 777.565s (0.07%)
Artifact size: 366.29 MiB -> 366.27 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 24, 2025
@fee1-dead
Copy link
Member Author

Not sure why this would be a regression, would you mind reviewing and let me know what you think? @petrochenkov

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 24, 2025
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