Skip to content
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

Merged
merged 3 commits into from Jan 19, 2023

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Jan 18, 2023

In BranchTarget, you only need id/ctx or block.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

yjit_alloc_size:          9927949

After

yjit_alloc_size:          8986243

@k0kubun k0kubun marked this pull request as ready for review January 19, 2023 01:22
@matzbot matzbot requested a review from a team January 19, 2023 01:23
yjit/src/core.rs Outdated Show resolved Hide resolved
yjit/src/core.rs Outdated Show resolved Hide resolved
Copy link
Member

@XrXr XrXr left a 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;
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

@k0kubun k0kubun merged commit 5ce0c13 into ruby:master Jan 19, 2023
@k0kubun k0kubun deleted the yjit-branch-target branch January 19, 2023 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants