feat: make the Assembler work in debug mode, remove optionality#2396
feat: make the Assembler work in debug mode, remove optionality#2396
Conversation
7e7a386 to
a167f8d
Compare
8800947 to
1e1ff22
Compare
|
Sorry - I merged #2366 before looking at this one. Could you merge the latest |
1e1ff22 to
c986bb5
Compare
|
@bobbinth No worries, I never intend to merge feature branches into each other anyway, all my PRs are always meant to be seen as a queue of things that all merge to main (or in this case |
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! I didn't really review the .snap file changes, but covered pretty much everything else and left a few small comments inline.
I'm not sure we fully realized this when we opened the issue. So with #2368 what we're saying is:
Is this really what we want? Looking back at the initial conversation, I think what really we wanted was for debug mode to be the default so that we don't need any
With this new approach, I just feel like we've made it harder for ourselves to obtain the "release mode |
|
Just to add some follow up after the sync call today: I think we may be able to get away from needing decorators entirely now that we have operation indexing/ranging. Doing so would probably mean removing the existing So, TL;DR, without decorators, we could move to a model without the need for node fingerprinting (or at least, fingerprinting would only need to deal with side-effecting operations like those that manipulate the advice provider), and all debugging-related information could be stored in a separate data structure from the MAST itself (only needing to provide some means to map operation indices/ranges to associated debug info). That said, we could make those changes after this is merged, so I don't see it as blocking or anything, just a logical next step. |
|
I'll hold off on merging this now (though, I think there are still arguments for doing so) - let's discuss this in more detail during our debug sync (hopefully tomorrow). |
68f9849 to
1b08e16
Compare
|
As requested, here's the script to measure the MastForest size. (use as an example in miden-vm) After: |
plafer
left a comment
There was a problem hiding this comment.
LGTM!
From the serialization size, we see that only 30 MAST nodes were removed by compaction (~4%), i.e. we don't get a lot of benefit from compacting. Makes sense to me to ask the user to call an explicit compact() method if they really want compaction.
Very interesting! Thank you for running this comparison! So, the serialized size roughly tripled, but given that the overall size is pretty small, I think this is fine. A couple of things I found surprising:
One other thing that would be good to do is to run our |
…nality - Remove conditional debug logic from assembler compile_body (if/else, while loops) - Always enable instruction tracking and debug decorators in instruction/mod.rs - Update testing utilities to remove debug mode control - Fix external callers across codebase to remove with_debug_mode() calls - Preserve all debug functionality but make it permanently enabled Progress on #1821
…g functionality - Removed in_debug_mode field from Assembler struct - Removed debug mode accessor and setter methods - Always execute debug decorator code paths (if/else, while loops, instruction tracking) - Updated testing utilities to remove debug mode control - Fixed external callers across codebase to remove debug mode dependencies - Updated test assertions to reflect new expected behavior with debug decorators - Updated all snapshot tests to include asmOp decorators - Fixed linting warnings Resolves #1821: always include debug info when assembling
- Update get_masm_program() to always use assembler debug mode - Remove Debug enum and related CLI functionality - Remove with-debug-info feature from stdlib and Makefile - Update all CLI callers to remove debug mode parameters - Preserve VM debug mode via --release flag for ExecutionOptions - All tests pass - assembler debug mode always enabled, VM debug mode optional Fully addresses issue #1821: always include debug info when assembling
Test that demonstrates how the CLI --release flag controls processor debug mode. The tests show that: - CLI without --release: debug mode = ON (enable_debugging() = true) - CLI with --release: debug mode = OFF (enable_debugging() = false) - CLI with --trace: both tracing = true AND debug mode = true - Trace decorators execute when tracing is enabled, regardless of debug mode
- Convert test_assembler_debug_info_conditional to test_assembler_debug_info_present: Now tests that debug info is always present instead of conditionally testing debug modes - Update duplicate_nodes test to duplicate_nodes_with_debug_decorators: Now tests functional equivalence while accounting for more nodes due to unique debug decorators - Add proper imports and fix API calls for test execution with processor dependencies - Remove unused imports and improve test accuracy for always-enabled debug mode behavior These changes make tests more robust and accurate for the post-issue-1821 codebase where assembler debug mode is always enabled, providing better test coverage.
- Remove unused TESTS section from miden-vm/src/cli/data.rs - Remove obsolete with_debug_info method from crates/assembly/src/testing.rs - Extract duplicate code into create_asmop_decorator helper function in assembler.rs - Fix test that used removed with_debug_info method
1b08e16 to
a0b2583
Compare
Comments
I would assume so, yes. Deserialize benchmark (on M4)origin/next (baseline):
huitseeker/issue-1821 (this branch):
Performance Impact: 18% performance degradation; ~2.4ms increase in deserialization time. |
This looks acceptable - so, I'll merge this PR. Maybe at some point later on we could experiment with "smart deserialization" - e.g., indicate during deserialization whether we want the debug info or now, and if not, then we'd skip deserializing this part of the |
…corator optionality This commit manually re-implements the ability to conditionally disable decorators by reverting the changes from PR 0xMiden#2396 (6e65482) on the origin/next branch (Winterfell v0.21.0, commit c8e1833). Changes: - Added in_debug_mode field to Assembler (defaults to false) - Added with_debug_mode(), set_debug_mode(), in_debug_mode() methods - Made decorator creation conditional in instruction/mod.rs - Made Breakpoint and Debug instructions conditional - Made if/loop node decorators conditional in assembler.rs - Updated CLI files to pass debug_on parameter based on --release flag Performance results: - WITH --release: 3154 ms (decorators disabled) - WITHOUT --release: 3168 ms (decorators enabled) This confirms the reversion logic is correct and Winterfell baseline performance is ~3.2s regardless of decorator presence.
…conditional This commit completes the reversion of PR 0xMiden#2396 by making instruction-level decorators conditional on debug mode. The previous reversion (15d26d7 and 46ecb01) only made control flow decorators (if/loop) conditional, but left instruction tracking and cycle count decorators unconditional. Changes in instruction/mod.rs: - Wrap instruction tracking with if self.in_debug_mode() - Wrap decorator creation for new nodes with if self.in_debug_mode() - Make cycle count setting conditional: if self.in_debug_mode() && !can_create_node - Make Breakpoint instruction conditional - Make Debug instruction conditional This matches the complete reversion in test-revert-on-next (commit 3aeff6a). Expected impact: With --release flag, NO decorators should be created, resulting in smaller MastForest and potentially better performance.
On top of #2366.
This removes the optionality of "turning on" debug mode in the
Assembler, fixing #1821. As an unavoidable consequence, we lose the ability to deduplicate between nodes, which are now all equipped with uniqueAsmOps. — though @plafer may have other ideas on this topic, and this PR could serve as a conversation starter.We will recover compactness in
MastForestrepresentation when we purge suchMastForests of decorators and solve #2368.Adds a test to check the CLI still controls whether the processor (unchanged) still executes in debug mode depending on the
--releaseparameter (this feature is orthogonal to the scope of this PR, we're just documenting its working with this test).Fixes #1821