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
YJIT: Remove duplicated information in BranchTarget #7151
Conversation
19c01c7
to
36765cf
Compare
36765cf
to
19638b5
Compare
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.
Nice! Space optimize pointer-ful data structure not that bad to do thanks to Rust :) Just one small request...
for target_idx in 0..=1 { | ||
if let Some(target) = pred_branch.targets[target_idx].as_ref() { | ||
if target.get_block().as_ref() == Some(blockref) { | ||
pred_branch.targets[target_idx] = None; |
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.
So, I remember considering doing this when I first introduced BranchTarget
and I got scared that this state where .block=None, but .address=Some...
is important. I'd say it's a very very small risk and it's definitely a good time to take such risk right now. In case it does end up being important, could you make a note of this in the commit log? We should just keep this in the back of our mind in case it come up; we'll have to rely on memory for this one.
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.
Sure, I'll make a note of this in the commit message when squash-merging this.
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.
summarized my intention in the commit message of 5ce0c13. Let me know if I'm missing something.
In
BranchTarget
, you only needid
/ctx
orblock.blockid
/block.ctx
at a time. If you encode that constraint in the type, we can save some space by eliminating the duplication.Impact
With macOS stats build on railsbench,
yjit_alloc_size
is reduced from 9.9MB to 9.0MB.Before
After