Skip to content

Conversation

@huitseeker
Copy link
Contributor

@huitseeker huitseeker commented Jan 7, 2026

On top of #2466 #2469 #2470. Adds support for serializing MastForest without debug information, producing smaller output files for production deployment.

  • Add FLAG_STRIPPED (0x01) to indicate debug info is omitted
  • Add MastForest::write_stripped() public method, redirect to a proxy newtype (for type safety).
  • Deserializer auto-detects format and creates empty DebugInfo when stripped
  • Reject unknown flags (reserved bits must be zero)

Together with the above PRs this is stacked on, closes #1580.

Note: this complements rather than replaces the in-memory decorator stripping from #2108, which remains useful for improving execution and proving performance.

@huitseeker huitseeker requested review from bobbinth and plafer January 7, 2026 13:57
@huitseeker huitseeker marked this pull request as ready for review January 7, 2026 14:42
@huitseeker huitseeker force-pushed the huitseeker/mastforest-deserialization branch from 4406e14 to 9492508 Compare January 7, 2026 18:31
@huitseeker huitseeker force-pushed the serialize-debuginfo-directly branch from 7c4a99e to c88a02a Compare January 7, 2026 18:42
@huitseeker huitseeker force-pushed the huitseeker/mastforest-deserialization branch from 9492508 to 9ddd236 Compare January 7, 2026 18:43
@huitseeker huitseeker force-pushed the serialize-debuginfo-directly branch from c88a02a to 65a4972 Compare January 7, 2026 19:04
@huitseeker huitseeker force-pushed the huitseeker/mastforest-deserialization branch from 9ddd236 to c47eabf Compare January 7, 2026 19:06
@huitseeker huitseeker force-pushed the serialize-debuginfo-directly branch from 65a4972 to 7dc6b6e Compare January 7, 2026 19:22
@huitseeker huitseeker force-pushed the huitseeker/mastforest-deserialization branch from c47eabf to 4f4704c Compare January 7, 2026 19:23
Base automatically changed from serialize-debuginfo-directly to next January 7, 2026 19:37
Add support for serializing MastForest without debug information,
producing smaller output files for production deployment.

Changes:
- Update header format: MAST (4 bytes) + FLAGS (1 byte) + VERSION (3 bytes)
- Add FLAG_STRIPPED (0x01) to indicate debug info is omitted
- Add MastForest::write_stripped() public method
- Deserializer auto-detects format and creates empty DebugInfo when stripped
- Reject unknown flags (reserved bits must be zero)
@huitseeker huitseeker force-pushed the huitseeker/mastforest-deserialization branch from 4f4704c to 9f1e016 Compare January 7, 2026 19:38
Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

Awesome, LGTM!

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you!

One thought for the future: stripping debug info removes most but not all debug-related info from the forest. Specifically, what is not removed are the inner values of Assert, U32assert2, and MpVerify operations. These contain error codes that probably are not super useful if we don't care about debugging.

There isn't a simple way to get rid of these though because operation serialization is handled pretty far deep in the stack.

Separately (and also not for this PR), I do think we should rename MastForest::strip_decorators() into something more like MastForest::clear_debug_info() because this method does more than just strip decorators.

Comment on lines +137 to +139
// node & decorator counts
target.write_usize(self.nodes.len());
// Expected to be used in #2504. Remove if this issue is resolved without using.
target.write_usize(self.debug_info.num_decorators());
target.write_usize(if stripped { 0 } else { self.debug_info.num_decorators() });
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but I'm still not sure we need to serialize these values.

@huitseeker huitseeker merged commit 59dc6e7 into next Jan 8, 2026
16 checks passed
@huitseeker huitseeker deleted the huitseeker/mastforest-deserialization branch January 8, 2026 09:53
huitseeker added a commit that referenced this pull request Jan 8, 2026
- Add method name `write_stripped()` to #2549 entry
- Fix typo in #2554 entry: clear_debug_info (with underscore)
huitseeker added a commit that referenced this pull request Jan 8, 2026
- Add method name `write_stripped()` to #2549 entry
- Fix typo in #2554 entry: clear_debug_info (with underscore)
huitseeker added a commit that referenced this pull request Jan 8, 2026
- Add method name `write_stripped()` to #2549 entry
- Fix typo in #2554 entry: clear_debug_info (with underscore)
huitseeker added a commit that referenced this pull request Jan 8, 2026
* refactor: rename strip_decorators to clear_debug_info

The method clears the entire DebugInfo, not just decorators.

* chore: Changelog

* chore: fix CHANGELOG entries for #2549 and #2554

- Add method name `write_stripped()` to #2549 entry
- Fix typo in #2554 entry: clear_debug_info (with underscore)
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.

Allow to truncate decorator data when serializing MAST

4 participants