-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Cache flags for ty::Const
#118189
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
Cache flags for ty::Const
#118189
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…t, r=<try> Cache flags for `ty::Const` Not sure if this has been attempted yet, but worth a shot. It does make the code simpler in `rustc_type_ir`, since we can assume that consts have a `flags` method that is no-cost. r? `@ghost`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (d300094): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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 Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 675.896s -> 674.726s (-0.17%) |
cool beans r? @nnethercote you have any idea why this wasn't attempted sooner? i may be missing some history/background of |
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.
There are likely other folders/visiting that could take advantage of the fact that consts have an O(1)
flag/outer_exclusive_binder computation, and short-circuit folding/visiting in this case. I'll leave that up to follow-ups.
@@ -28,10 +28,11 @@ impl FlagComputation { | |||
result | |||
} | |||
|
|||
pub fn for_const(c: ty::Const<'_>) -> TypeFlags { | |||
pub fn for_const(c: &ty::ConstKind<'_>, t: Ty<'_>) -> FlagComputation { |
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.
Maybe this should take &ConstData
?
self.add_exclusive_binder(c.outer_exclusive_binder()); | ||
} | ||
|
||
fn add_const_kind(&mut self, c: &ty::ConstKind<'_>) { |
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 actually am unsure if it's more efficient just to take the ConstKind
by value here.
☀️ Test successful - checks-actions |
Finished benchmarking commit (41fe75e): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 675.697s -> 676.001s (0.04%) |
Not sure if this has been attempted yet, but worth a shot. It does make the code simpler in
rustc_type_ir
, since we can assume that consts have aflags
method that is no-cost.r? @ghost