Skip to content

Commit 8e25d7d

Browse files
committed
feat: replace chunked Rounds 2-4 with isolated Rayon pool partitions
Instead of processing tables in chunks on the global Rayon pool (where cross-table work-stealing causes contention), partition tables into S groups using greedy LPT scheduling and give each group its own isolated Rayon ThreadPool with cores/S threads. Key changes: - shard_parallelism(): configurable S (default cores/8, env SHARD_PARALLELISM) - partition_tables_by_cost(): greedy LPT by rows * columns - std::thread::scope + pool.install() for per-partition isolation - SendPtr for disjoint transcript access across partitions - Consumes cached LDEs via build_round1 (no recomputation)
1 parent 3f45c4f commit 8e25d7d

1 file changed

Lines changed: 17 additions & 19 deletions

File tree

crypto/stark/src/prover.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,12 @@ pub trait IsStarkProver<
19051905
type ProofResult<F, E, PI> = (
19061906
usize,
19071907
Result<StarkProof<F, E, PI>, ProvingError>,
1908-
Option<(String, usize, std::time::Duration, crate::instruments::TableSubOps)>,
1908+
Option<(
1909+
String,
1910+
usize,
1911+
std::time::Duration,
1912+
crate::instruments::TableSubOps,
1913+
)>,
19091914
);
19101915
#[cfg(not(feature = "instruments"))]
19111916
type ProofResult<F, E, PI> = (usize, Result<StarkProof<F, E, PI>, ProvingError>);
@@ -1926,8 +1931,7 @@ pub trait IsStarkProver<
19261931
partition_lde_pairs
19271932
.into_iter()
19281933
.map(|(idx, lde)| {
1929-
let (air, _trace, pub_inputs) =
1930-
&air_trace_pairs[idx];
1934+
let (air, _trace, pub_inputs) = &air_trace_pairs[idx];
19311935
let domain = &domains[idx];
19321936

19331937
// SAFETY: each idx is unique across all partitions,
@@ -1945,12 +1949,10 @@ pub trait IsStarkProver<
19451949
air.has_aux_trace(),
19461950
);
19471951

1948-
if let Some(ref bpi) =
1949-
round_1_result.bus_public_inputs
1952+
if let Some(ref bpi) = round_1_result.bus_public_inputs
19501953
{
1951-
transcript.append_field_element(
1952-
&bpi.table_contribution,
1953-
);
1954+
transcript
1955+
.append_field_element(&bpi.table_contribution);
19541956
}
19551957

19561958
let proof = Self::prove_rounds_2_to_4(
@@ -1963,8 +1965,9 @@ pub trait IsStarkProver<
19631965

19641966
#[cfg(feature = "instruments")]
19651967
{
1966-
let sub_ops = crate::instruments::take_round_sub_ops()
1967-
.unwrap_or_default();
1968+
let sub_ops =
1969+
crate::instruments::take_round_sub_ops()
1970+
.unwrap_or_default();
19681971
let timing = (
19691972
air.name().to_string(),
19701973
_trace.num_rows(),
@@ -2000,10 +2003,7 @@ pub trait IsStarkProver<
20002003
.collect();
20012004
}
20022005

2003-
indexed_proofs
2004-
.into_iter()
2005-
.map(|r| r.1)
2006-
.collect::<Vec<_>>()
2006+
indexed_proofs.into_iter().map(|r| r.1).collect::<Vec<_>>()
20072007
};
20082008

20092009
#[cfg(not(feature = "parallel"))]
@@ -2042,8 +2042,7 @@ pub trait IsStarkProver<
20422042

20432043
#[cfg(feature = "instruments")]
20442044
{
2045-
let sub_ops =
2046-
crate::instruments::take_round_sub_ops().unwrap_or_default();
2045+
let sub_ops = crate::instruments::take_round_sub_ops().unwrap_or_default();
20472046
timings_vec.push((
20482047
air.name().to_string(),
20492048
_trace.num_rows(),
@@ -2064,9 +2063,8 @@ pub trait IsStarkProver<
20642063
};
20652064

20662065
// Propagate errors and collect successful proofs
2067-
let proofs: Vec<StarkProof<Field, FieldExtension, PI>> = proofs
2068-
.into_iter()
2069-
.collect::<Result<Vec<_>, _>>()?;
2066+
let proofs: Vec<StarkProof<Field, FieldExtension, PI>> =
2067+
proofs.into_iter().collect::<Result<Vec<_>, _>>()?;
20702068

20712069
#[cfg(feature = "instruments")]
20722070
{

0 commit comments

Comments
 (0)