-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add fast path to is_descendant_of
#91043
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
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
I think we have an invariant that either |
I don't think that is true because a macro can have a nested macro call to an external crate? |
Macros are expanded from the outer in. |
Okay I think I get it, tell me if this sounds right. A stack of nested macro calls are all triggered by one outermost macro call in a particular crate. All the expansions in the stack belong to that crate. Should I modify |
Indeed, we should probably make every caller benefit from the optimization. |
91e29ce
to
6bb464a
Compare
ExpnId::is_descendant
is_descendant_of
6bb464a
to
b708abf
Compare
Whoops. @petrochenkov let me know if your self-assignment was a mistake and I can review |
That's not necessarily true if the parent is a root because we don't yet preserve krate IDs for root expansions, but otherwise this should be true. |
@jackh726 |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit b708abf68d0f335dbd6b3c9021f68f5d3c99b527 with merge 8cf5997459fd458031256a1986c32a922e0d6c0a... |
☀️ Try build successful - checks-actions |
Queued 8cf5997459fd458031256a1986c32a922e0d6c0a with parent b8e5ab2, future comparison URL. |
Finished benchmarking commit (8cf5997459fd458031256a1986c32a922e0d6c0a): comparison url. Summary: This change led to small relevant mixed results 🤷 in compiler performance.
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 @bors rollup=never |
Looks like a minor improvement. |
Could you add
|
b708abf
to
ac8d514
Compare
I also changed a @rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I know this code enough to actually r+ this, so I'll defer to @petrochenkov.
With that being said, the changes here seem okay to me.
@@ -1223,6 +1240,7 @@ pub fn register_expn_id( | |||
data: ExpnData, | |||
hash: ExpnHash, | |||
) -> ExpnId { | |||
debug_assert!(data.parent == ExpnId::root() || krate == data.parent.krate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a regular assert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine as is, the assert will be removed anyway when root expansions start keeping their crate IDs.
@bors r+ |
📌 Commit ac8d514 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (44723c5): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
No description provided.