-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Refactor vtable encoding and optimize it for the case of multiple marker traits #113856
Conversation
I always forget what the `bool` means :/
Reasoning: if the stack is empty, the loop will be infinite, so the assumption is that the stack can't be non empty. Unwrap makes the assumption more clear (and removes an indentation level)
Less explicit loops -- easier to read.
1. Hide the option as an iterator, so it's nicer to work with 2. Replace a loop with `find`
r? @oli-obk (rustbot has picked a reviewer for you, use r? to override) |
That was a pleasure to review. I had several comments, and subsequent commits resolved them, so now I got nothing. @bors r+ rollup=never (theoretical perf impact and changing vtable layout could be desirable to get bisected in the future) |
☀️ Test successful - checks-actions |
Finished benchmarking commit (399b068): comparison URL. Overall result: ❌✅ regressions and 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 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: 648.763s -> 650.713s (0.30%) |
Method(<S as T>::method), | ||
TraitVPtr(<S as T>), | ||
TraitVPtr(<S as M2>), |
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.
Why is TraitVPtr needed for M2?
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.
The short answer: it is not needed. The longer answer is that we currently keep the order of all things from the traits, so since M2
comes after T
, it can't be inlined there. I've filled #114942 to track this.
This PR does two things
prepare_vtable_segments
(this was motivated by the other change,prepare_vtable_segments
was quite hard to understand and while trying to edit it I've refactored it)loop
s labeledbreak
s/continue
s whenever there is a simpler solution?
Fixes #113840
cc @crlf0710
Review wise it's probably best to review each commit individually, as then it's more clear why the refactoring is correct.
I can split the last two commits (which change behavior) into a separate PR if it makes reviewing easier