openvm_benchmark_synthetic/segment_profile.rs
1//! Consumer-side schema for the segment-shape profile JSONL.
2//!
3//! These structs are the deserialization targets for each line of a
4//! profile captured by the upstream `SHADOW_BENCH_PROFILE_PATH` probe.
5//! The producer that writes the JSONL lives in `stark-backend`'s prover
6//! module; nothing in this directory captures profiles — we only
7//! consume them.
8//!
9//! [`ProfileTraceWidth`] is intentionally a *local* mirror of the
10//! captured wire shape rather than a re-use of `keygen::types::TraceWidth`:
11//! the captured JSONL is a stable on-disk format, while the upstream type
12//! evolves (e.g. the `after_challenge` field was removed upstream after
13//! these profiles were captured). Decoupling lets old captures keep
14//! deserializing against newer backends. `#[serde(default)]` on optional
15//! fields gives forward/backward schema tolerance.
16
17use openvm_stark_backend::interaction::BusIndex;
18use serde::{Deserialize, Serialize};
19
20/// Width fields as captured in the profile JSONL — independent of the
21/// upstream `TraceWidth` so schema evolution upstream doesn't break
22/// replay of older captures.
23#[derive(Clone, Debug, Serialize, Deserialize)]
24pub struct ProfileTraceWidth {
25 #[serde(default)]
26 pub preprocessed: Option<usize>,
27 #[serde(default)]
28 pub cached_mains: Vec<usize>,
29 pub common_main: usize,
30 #[serde(default)]
31 pub after_challenge: Vec<usize>,
32}
33
34#[derive(Clone, Debug, Serialize, Deserialize)]
35pub struct AirShapeRecord {
36 pub air_name: String,
37 pub air_id: usize,
38 pub log_height: usize,
39 pub height: usize,
40 pub width: ProfileTraceWidth,
41 pub num_constraints: usize,
42 pub num_interactions: usize,
43 pub max_constraint_degree: usize,
44 /// Per-interaction `bus_index`. `len() == num_interactions`.
45 pub buses: Vec<BusIndex>,
46 /// Per-interaction message length (number of field expressions).
47 /// `len() == num_interactions`. Added in schema v2.
48 pub interaction_message_lens: Vec<usize>,
49 /// Per-interaction `count_weight` (logup soundness parameter).
50 /// `len() == num_interactions`. Added in schema v2.
51 pub interaction_count_weights: Vec<u32>,
52}
53
54#[derive(Clone, Debug, Serialize, Deserialize)]
55pub struct SegmentProfile {
56 pub schema: String,
57 pub segment_idx: usize,
58 pub global_max_constraint_degree: usize,
59 pub airs: Vec<AirShapeRecord>,
60}