From e39a328ec3ddc458b90e0e78a87f3ed13d9c6720 Mon Sep 17 00:00:00 2001 From: Aviv Greenburg Date: Mon, 23 Dec 2024 14:05:50 +0200 Subject: [PATCH] chore(blockifier): add feild channel_size to contract_class_manager_config --- config/sequencer/default_config.json | 5 +++++ crates/blockifier/src/blockifier/config.rs | 9 +++++++++ crates/blockifier/src/state/contract_class_manager.rs | 7 +++---- crates/native_blockifier/src/py_objects.rs | 4 ++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/config/sequencer/default_config.json b/config/sequencer/default_config.json index 0d3d8ef4d6..3b84ffeac1 100644 --- a/config/sequencer/default_config.json +++ b/config/sequencer/default_config.json @@ -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", diff --git a/crates/blockifier/src/blockifier/config.rs b/crates/blockifier/src/blockifier/config.rs index aca073f1b4..e49fb7fbac 100644 --- a/crates/blockifier/src/blockifier/config.rs +++ b/crates/blockifier/src/blockifier/config.rs @@ -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)] @@ -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 { @@ -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, } } } @@ -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, + ), ]) } } diff --git a/crates/blockifier/src/state/contract_class_manager.rs b/crates/blockifier/src/state/contract_class_manager.rs index fbb697f3b9..ebbb7102cd 100644 --- a/crates/blockifier/src/state/contract_class_manager.rs +++ b/crates/blockifier/src/state/contract_class_manager.rs @@ -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. /// @@ -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(); @@ -127,7 +126,7 @@ impl ContractClassManager { log::error!( "Compilation request channel is full (size: {}). Compilation request for \ class hash {} was not sent.", - CHANNEL_SIZE, + DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE, class_hash ) } diff --git a/crates/native_blockifier/src/py_objects.rs b/crates/native_blockifier/src/py_objects.rs index d2390eeaec..9cc2eb109d 100644 --- a/crates/native_blockifier/src/py_objects.rs +++ b/crates/native_blockifier/src/py_objects.rs @@ -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; @@ -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 { @@ -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, } } } @@ -183,6 +186,7 @@ impl From 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, } } }