Skip to content

fix(core): keep MAST merge from growing stripped forests#3044

Open
huitseeker wants to merge 5 commits intonextfrom
huitseeker/3035-mast-compact-size
Open

fix(core): keep MAST merge from growing stripped forests#3044
huitseeker wants to merge 5 commits intonextfrom
huitseeker/3035-mast-compact-size

Conversation

@huitseeker
Copy link
Copy Markdown
Collaborator

This fixes a case where MastForest::compact() could make a stripped forest larger instead of smaller.

The root cause is twofold. First, merge rebuilt basic blocks from the padded operation iterator, so padding ops became "organic" serialized ops. Second, after debug info was cleared, compact still wrote empty node decorator rows for every merged node.

The fix keeps the original basic-block batches during merge and skips empty node decorator rows. The op decorator CSR is still kept as a valid empty structure after debug info is cleared.

Closes #3035.

@huitseeker huitseeker changed the title Huitseeker/3035 mast compact size fix(core): keep MAST merge from growing stripped forests Apr 22, 2026
@huitseeker huitseeker force-pushed the huitseeker/3035-mast-compact-size branch from 0bc8f93 to ad3d1d8 Compare April 22, 2026 12:08
Copy link
Copy Markdown
Collaborator

@bitwalker bitwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Ping me for a re-review after this is marked ready (if needed)

@huitseeker huitseeker marked this pull request as ready for review April 22, 2026 18:32
Copy link
Copy Markdown
Collaborator

@greenhat greenhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for a prompt response!

@huitseeker huitseeker force-pushed the huitseeker/3035-mast-compact-size branch from ad3d1d8 to 22c04a7 Compare April 23, 2026 12:49
@bitwalker
Copy link
Copy Markdown
Collaborator

@huitseeker Maybe we should apply this to main so it can go out in 0.22.2? It looks like it should be a non-breaking change unless I missed something

@huitseeker huitseeker force-pushed the huitseeker/3035-mast-compact-size branch from 22c04a7 to 2e4ff55 Compare April 24, 2026 10:46
@huitseeker
Copy link
Copy Markdown
Collaborator Author

@bitwalker Is this a blocker for something? The improvements in serialization size from this fix are in the low single-digit percentages. I agree there is no semver issue, but I am not sure if it's worth the trouble.

@bitwalker
Copy link
Copy Markdown
Collaborator

We were observing double-digit reduction in size due to compaction previously on some of our example programs (e.g. 18k -> 13k in one of them), but obviously that can vary significantly. In any case, without compaction, it's a lot easier to hit the account/note code size limits when compiling Rust programs - so it's not a blocker for some feature, but it does directly impact whether Rust components that run up against the limit will be usable or not. Since users won't get stuff in next for quite some time (at least a month?), it's probably worth it.

Since we also have at least one other fix queued up in main, it probably makes sense to include this if it isn't going to be a major pain to do so. I was thinking the divergence between main and next in this code wouldn't be too bad since we just did a release, but you'd have a better idea than me whether this would be annoying to backport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MastForest::compact increases the MAST size

3 participants