Skip to content

Commit

Permalink
Make MAX_DEGREE_LOG configurable (#1677)
Browse files Browse the repository at this point in the history
Pulled out of #1676, where it helps making the tests run faster.

I think this could possibly be removed by #1667 again.
  • Loading branch information
georgwiese committed Aug 12, 2024
1 parent e95ac18 commit d87a33c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
env:
CARGO_TERM_COLOR: always
POWDR_GENERATE_PROOFS: "true"
MAX_DEGREE_LOG: "10"

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion backend/src/composite/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub(crate) fn machine_fixed_columns<F: FieldElement>(
);
match machine_degrees.iter().next() {
Some(&degree) => iter::once(degree as usize).collect(),
None => (MIN_DEGREE_LOG..=MAX_DEGREE_LOG)
None => (MIN_DEGREE_LOG..=*MAX_DEGREE_LOG)
.map(|log_size| 1 << log_size)
.collect(),
}
Expand Down
21 changes: 19 additions & 2 deletions executor/src/constant_evaluator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::{
collections::{BTreeMap, HashMap},
env,
sync::{Arc, RwLock},
};

pub use data_structures::{get_uniquely_sized, get_uniquely_sized_cloned, VariablySizedColumn};
use itertools::Itertools;
use lazy_static::lazy_static;
use powdr_ast::{
analyzed::{Analyzed, FunctionValueDefinition, Symbol, TypedExpression},
parsed::{
Expand All @@ -19,7 +21,22 @@ use rayon::prelude::{IntoParallelIterator, ParallelIterator};
mod data_structures;

pub const MIN_DEGREE_LOG: usize = 5;
pub const MAX_DEGREE_LOG: usize = 22;
lazy_static! {
// The maximum degree can add a significant cost during setup, because
// the fixed columns need to be committed to in all sizes up to the max degree.
// This gives the user the possibility to overwrite the default value.
pub static ref MAX_DEGREE_LOG: usize = {
let default_max_degree_log = 22;

let max_degree_log = match env::var("MAX_DEGREE_LOG") {
Ok(val) => val.parse::<usize>().unwrap(),
Err(_) => default_max_degree_log,
};
log::info!("For variably-sized machine, the maximum degree is 2^{max_degree_log}. \
You can set the environment variable MAX_DEGREE_LOG to change this value.");
max_degree_log
};
}

/// Generates the fixed column values for all fixed columns that are defined
/// (and not just declared).
Expand All @@ -37,7 +54,7 @@ pub fn generate<T: FieldElement>(analyzed: &Analyzed<T>) -> Vec<(String, Variabl
let values = if let Some(degree) = poly.degree {
generate_values(analyzed, degree, &name, value, index).into()
} else {
(MIN_DEGREE_LOG..=MAX_DEGREE_LOG)
(MIN_DEGREE_LOG..=*MAX_DEGREE_LOG)
.map(|degree_log| {
let degree = 1 << degree_log;
generate_values(analyzed, degree, &name, value, index)
Expand Down
2 changes: 1 addition & 1 deletion executor/src/witgen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl<'a, T: FieldElement> FixedData<'a, T> {
}

fn common_degree<'b>(&self, ids: impl IntoIterator<Item = &'b PolyID>) -> DegreeType {
self.common_set_degree(ids).unwrap_or(1 << MAX_DEGREE_LOG)
self.common_set_degree(ids).unwrap_or(1 << *MAX_DEGREE_LOG)
}

fn is_variable_size<'b>(&self, ids: impl IntoIterator<Item = &'b PolyID>) -> bool {
Expand Down

0 comments on commit d87a33c

Please sign in to comment.