Overview
Theanalyze_<function_name> function executes the guest program with given inputs and returns detailed statistics about the execution trace. This is useful for understanding program behavior, optimizing performance, and estimating proof generation costs.
Function Signature
Parameters
The same parameters as the guest function:- Public inputs - Regular function parameters
- Untrusted advice - Parameters that will be passed as untrusted advice
- Trusted advice - Parameters that will be passed as trusted advice
Return Value
Returns aProgramSummary containing:
- Execution trace statistics
- Instruction counts by type
- Memory access patterns
- Cycle counts
- Other performance metrics
ProgramSummary API
The returnedProgramSummary provides methods for:
Writing to File
Usage Examples
Basic Analysis
Analyzing Different Input Sizes
Analyzing Complex Inputs
With Cycle Tracking
Combine with cycle tracking in guest code:Analysis Output Format
The generated analysis file typically includes:- Trace Length - Total number of execution cycles
- Instruction Breakdown - Count of each RISC-V instruction executed
- Memory Statistics - RAM and register access patterns
- Cycle Tracking - Named cycle counts (if using
start_cycle_tracking/end_cycle_tracking) - Advice Usage - Size of advice tape if advice functions were used
Use Cases
Performance Optimization
Identify expensive operations in your guest code:Proof Cost Estimation
Estimate proving costs before running the full prover:Debugging
Understand program behavior and identify issues:Generated From
For a function annotated with#[jolt::provable]:
analyze_fib that accepts the same parameters.
Important Notes
- Analysis executes the guest program but does not generate a proof
- Much faster than proof generation - useful for rapid iteration
- Analysis output depends on the specific input - different inputs may have different characteristics
- The analysis includes all features enabled during compilation (std/no-std, backtrace, profiling)
Profiling Features
The guest program can be built with profiling features:backtrace = true- Includes stack trace informationprofile = true- Includes detailed profiling data
Related Functions
trace_to_file- Exports raw execution trace to binary filecompile- Compiles the guest program- Cycle tracking functions in guest code:
jolt::start_cycle_tracking(label: &str)jolt::end_cycle_tracking(label: &str)