Skip to content

Conversation

@plafer
Copy link
Contributor

@plafer plafer commented Jan 5, 2026

Closes #2535

As part of this change, we also added a new constructor FastProcessor::new_with_options(), which allows users to pass in a ExecutionOptions.

Base automatically changed from huitseeker/merge-main-into-next to next January 5, 2026 17:29
@plafer plafer force-pushed the plafer-2535-cycle-count-limit branch 2 times, most recently from 710a357 to 6e19dd6 Compare January 5, 2026 17:55
Copy link
Contributor

@Al-Kindi-0 Al-Kindi-0 left a comment

Choose a reason for hiding this comment

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

LGTM

@plafer plafer force-pushed the plafer-2535-cycle-count-limit branch 3 times, most recently from 3b1f781 to f3e2754 Compare January 5, 2026 19:33
Comment on lines -166 to +179
/// Creates a new `FastProcessor` instance, set to debug mode, with the given stack
/// and advice inputs.
/// Creates a new `FastProcessor` instance with the given stack and advice inputs, where
/// debugging and tracing are enabled.
///
/// # Panics
/// - Panics if the length of `stack_inputs` is greater than `MIN_STACK_DEPTH`.
pub fn new_debug(stack_inputs: &[Felt], advice_inputs: AdviceInputs) -> Self {
Self::initialize(stack_inputs, advice_inputs, true)
Self::new_with_options(
stack_inputs,
advice_inputs,
ExecutionOptions::default().with_debugging(true).with_tracing(),
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that I enabled tracing with the new_debug() to preserve former functionality (mostly in tests).

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 would be great to "normalize" ExecutionOptions at some point. For example, it is a bit odd that with_dubbing() takes a parameter while with_tracing() does not.

@plafer plafer force-pushed the plafer-2535-cycle-count-limit branch from f3e2754 to cbdabec Compare January 5, 2026 19:35
@plafer plafer force-pushed the plafer-2535-cycle-count-limit branch 2 times, most recently from 15bd24a to bcf0479 Compare January 5, 2026 21:07
@plafer plafer requested a review from Al-Kindi-0 January 5, 2026 21:07
Comment on lines 250 to 257
/// Returns true if decorators should be executed.
///
/// This corresponds to either being in debug mode (for debug decorators) or having tracing
/// enabled (for trace decorators).
fn should_execute_decorators(&self) -> bool {
self.in_debug_mode() || self.options.enable_tracing()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Al-Kindi-0 I re-requested a review, since I added this method since you approved (which I only noticed was needed when working on #2539). Basically, we should execute decorators not only in debug mode, but also when tracing is enabled.

This has the unfortunate consequence that the processor will be slowed down when only tracing (but not debug mode) is enabled.

This is a by-product of the fact that AsmOp decorators should not be lumped in with Debug and Trace decorators, since they do not need to be executed at runtime. Currently, if tracing mode is enabled (or even debug mode just for debug decorators), the processor needlessly loops through all AsmOp decorators, which really isn't needed - we only need to look them up when an error occurs. AsmOp decorators should be stored separately in their own CSR matrix. This is as previously discussed with @huitseeker.

Copy link
Contributor

Choose a reason for hiding this comment

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

Opened #2541 to track

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 good! Thank you! I left just a few small comments inline.

Also, now we are doing a bit more work on every cycle - did this have any noticeable impact on performance?

Comment on lines +187 to +191
pub fn new_with_options(
stack_inputs: &[Felt],
advice_inputs: AdviceInputs,
options: ExecutionOptions,
) -> Self {
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 we could consider encapsulating stack and advice inputs into a single struct - e.g., something like ProgramInputs.

Comment on lines -166 to +179
/// Creates a new `FastProcessor` instance, set to debug mode, with the given stack
/// and advice inputs.
/// Creates a new `FastProcessor` instance with the given stack and advice inputs, where
/// debugging and tracing are enabled.
///
/// # Panics
/// - Panics if the length of `stack_inputs` is greater than `MIN_STACK_DEPTH`.
pub fn new_debug(stack_inputs: &[Felt], advice_inputs: AdviceInputs) -> Self {
Self::initialize(stack_inputs, advice_inputs, true)
Self::new_with_options(
stack_inputs,
advice_inputs,
ExecutionOptions::default().with_debugging(true).with_tracing(),
)
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 would be great to "normalize" ExecutionOptions at some point. For example, it is a bit odd that with_dubbing() takes a parameter while with_tracing() does not.

Comment on lines +254 to +257
fn should_execute_decorators(&self) -> bool {
self.in_debug_mode() || self.options.enable_tracing()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add #[inline(always)] here as well?

Also, not for this PR, but I'm wondering if we should simplify the debug mode - basically, have a single setting that enables both debugging and tracing. I'm not really sure there is a lot of benefit of having them separate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we add #[inline(always)] here as well?

Done

Also, not for this PR, but I'm wondering if we should simplify the debug mode - basically, have a single setting that enables both debugging and tracing. I'm not really sure there is a lot of benefit of having them separate.

Agreed, though let's address this when we know whether better what tracing ends up looking like.

@plafer plafer force-pushed the plafer-2535-cycle-count-limit branch from bcf0479 to 2bf0d59 Compare January 5, 2026 21:26
@plafer plafer force-pushed the plafer-2535-cycle-count-limit branch from 2bf0d59 to 7685950 Compare January 5, 2026 21:30

if stopper.should_stop(self) {
ControlFlow::Break(())
if self.clk >= self.options.max_cycles() as usize {
Copy link
Contributor

Choose a reason for hiding this comment

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

To answer @bobbinth's question about performance impact: I ran make exec-info and a blake3 proving benchmark on both this branch and next.

Results (blake3_1to1 prove):

  • PR branch: total 33.1s, execute_for_trace 7.45ms, build_trace 78.3ms
  • next branch: total 33.1s, execute_for_trace 11.1ms, build_trace 87.0ms

No regression, execution is actually slightly faster on this branch (likely noise, but definitely not slower).

plafer added 5 commits January 6, 2026 09:27
…Two`

This is not an actual requirement, and some tests make use of fragments of size
that are not a power of 2.
We also add a new method `FastProcessor::should_execute_decorator()`, which
takes into account that we should execute decorators in debug mode *and*
when tracing is enabled.
…)` method.

Continuations should be passed directly rather than "fixing the continuation" after the call to `increment_clk()`
with `map_break()` as was done previously. This is generally cleaner, and allows the `increment_clk_*()` methods
to return internal errors as well.
plafer added 2 commits January 6, 2026 09:27
This is done in the new `FastProcessor::increment_clk_with_continuation()`.
@plafer plafer force-pushed the plafer-2535-cycle-count-limit branch from 7685950 to 231ef56 Compare January 6, 2026 14:28
@plafer plafer merged commit 75bcff1 into next Jan 6, 2026
16 checks passed
@plafer plafer deleted the plafer-2535-cycle-count-limit branch January 6, 2026 14:42
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.

Enforce cycle count limit

5 participants