File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ pub type HostProvider = FillProvider<
5151 RootProvider ,
5252> ;
5353
54+ /// The default concurrency limit for the builder if system call fails.
55+ pub const DEFAULT_CONCURRENCY_LIMIT : usize = 4 ;
56+
5457/// Configuration for a builder running a specific rollup on a specific host
5558/// chain.
5659#[ derive( Debug , Clone , FromEnv ) ]
@@ -150,7 +153,8 @@ pub struct BuilderConfig {
150153 /// The max number of simultaneous block simulations to run.
151154 #[ from_env(
152155 var = "CONCURRENCY_LIMIT" ,
153- desc = "The max number of simultaneous block simulations to run"
156+ desc = "The max number of simultaneous block simulations to run" ,
157+ optional
154158 ) ]
155159 pub concurrency_limit : usize ,
156160
@@ -276,4 +280,14 @@ impl BuilderConfig {
276280 pub const fn cfg_env ( & self ) -> SignetCfgEnv {
277281 SignetCfgEnv { chain_id : self . ru_chain_id }
278282 }
283+
284+ /// Get the concurrency limit for the current system.
285+ pub fn concurrency_limit ( & self ) -> usize {
286+ if self . concurrency_limit == 0 {
287+ std:: thread:: available_parallelism ( )
288+ . map ( |p| p. get ( ) )
289+ . unwrap_or ( DEFAULT_CONCURRENCY_LIMIT ) ;
290+ }
291+ self . concurrency_limit
292+ }
279293}
You can’t perform that action at this time.
0 commit comments