-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Use a lookup table in #[derive(Debug)]
for fieldless enums
#114190
Conversation
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 4d76b33 with merge fdbb5360b46d689c4d8ca16144ce40a45cb83099... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
I haven't looked at the implementation yet but my previous attempt at this (#109615) might be of interest |
Finished benchmarking commit (fdbb5360b46d689c4d8ca16144ce40a45cb83099): comparison URL. Overall result: ❌ regressions - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @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.
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 sizeResultsThis 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.
Bootstrap: 649.861s -> 651.137s (0.20%) |
/// const { ["A", "B", "C"] }[match self { | ||
/// Fieldless::A => 0usize, | ||
/// Fieldless::B => 1usize, | ||
/// Fieldless::C => 2usize, | ||
/// }], |
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 have been looking into a similar case recently as noted in #114106 (comment), and part of the problem might be the match
statement itself.
For data-less enums with dense/contiguous discriminants, you should be able to just use something like *self as u32
to use the discriminant directly as an index instead of via the match
roundtrip.
I don't think the perf results warrant landing this as-is, if you have other ideas that you'd like to try then we can re-run the benchmarking with those :) |
Closing given negative perf results and I don't really have any idea on how to improve this. |
Index into a constant array containing the Debug strings instead of matching directly.
Opening as draft since I don't know the performance implications of this, and would be nice to have a perf run done on this PR.
Closes #114106
Refs #114106 (comment), #106884