Skip to content

Commit

Permalink
chore(blockifier): add feild channel_size to contract_class_manager_c…
Browse files Browse the repository at this point in the history
…onfig
  • Loading branch information
avivg-starkware committed Dec 26, 2024
1 parent 6f09863 commit b7e2924
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@
"pointer_target": "versioned_constants_overrides.validate_max_n_steps",
"privacy": "Public"
},
"batcher_config.contract_class_manager_config.channel_size": {
"description": "The size of the compilation request channel.",
"privacy": "Public",
"value": 1000
},
"batcher_config.contract_class_manager_config.contract_cache_size": {
"description": "The size of the global contract cache.",
"privacy": "Public",
Expand Down
9 changes: 9 additions & 0 deletions crates/blockifier/src/blockifier/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig
use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam};
use serde::{Deserialize, Serialize};

use crate::state::contract_class_manager::DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE;
use crate::state::global_cache::GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST;

#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
Expand Down Expand Up @@ -69,6 +70,7 @@ pub struct ContractClassManagerConfig {
pub run_cairo_native: bool,
pub wait_on_native_compilation: bool,
pub contract_cache_size: usize,
pub channel_size: usize,
}

impl Default for ContractClassManagerConfig {
Expand All @@ -77,6 +79,7 @@ impl Default for ContractClassManagerConfig {
run_cairo_native: false,
wait_on_native_compilation: false,
contract_cache_size: GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST,
channel_size: DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE,
}
}
}
Expand All @@ -102,6 +105,12 @@ impl SerializeConfig for ContractClassManagerConfig {
"The size of the global contract cache.",
ParamPrivacyInput::Public,
),
ser_param(
"channel_size",
&self.channel_size,
"The size of the compilation request channel.",
ParamPrivacyInput::Public,
),
])
}
}
7 changes: 3 additions & 4 deletions crates/blockifier/src/state/contract_class_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ use crate::execution::native::contract_class::NativeCompiledClassV1;
use crate::state::global_cache::CachedCairoNative;
use crate::state::global_cache::{CachedCasm, ContractCaches};

#[cfg(feature = "cairo_native")]
const CHANNEL_SIZE: usize = 1000;
pub const DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE: usize = 1000;

/// Represents a request to compile a sierra contract class to a native compiled class.
///
Expand Down Expand Up @@ -94,7 +93,7 @@ impl ContractClassManager {
};
}

let (sender, receiver) = sync_channel(CHANNEL_SIZE);
let (sender, receiver) = sync_channel(config.channel_size);

std::thread::spawn({
let contract_caches = contract_caches.clone();
Expand Down Expand Up @@ -127,7 +126,7 @@ impl ContractClassManager {
log::error!(
"Compilation request channel is full (size: {}). Compilation request for \
class hash {} was not sent.",
CHANNEL_SIZE,
self.config.channel_size,
class_hash
)
}
Expand Down
4 changes: 4 additions & 0 deletions crates/native_blockifier/src/py_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::HashMap;
use blockifier::abi::constants;
use blockifier::blockifier::config::{ConcurrencyConfig, ContractClassManagerConfig};
use blockifier::bouncer::{BouncerConfig, BouncerWeights, BuiltinCount, HashMapWrapper};
use blockifier::state::contract_class_manager::DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE;
use blockifier::state::global_cache::GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST;
use blockifier::versioned_constants::VersionedConstantsOverrides;
use cairo_vm::types::builtin_name::BuiltinName;
Expand Down Expand Up @@ -165,6 +166,7 @@ pub struct PyContractClassManagerConfig {
pub run_cairo_native: bool,
pub wait_on_native_compilation: bool,
pub contract_cache_size: usize,
pub channel_size: usize,
}

impl Default for PyContractClassManagerConfig {
Expand All @@ -173,6 +175,7 @@ impl Default for PyContractClassManagerConfig {
run_cairo_native: false,
wait_on_native_compilation: false,
contract_cache_size: GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST,
channel_size: DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE,
}
}
}
Expand All @@ -183,6 +186,7 @@ impl From<PyContractClassManagerConfig> for ContractClassManagerConfig {
run_cairo_native: py_contract_class_manager_config.run_cairo_native,
wait_on_native_compilation: py_contract_class_manager_config.wait_on_native_compilation,
contract_cache_size: py_contract_class_manager_config.contract_cache_size,
channel_size: py_contract_class_manager_config.channel_size,
}
}
}

0 comments on commit b7e2924

Please sign in to comment.