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<
51
51
RootProvider ,
52
52
> ;
53
53
54
+ /// The default concurrency limit for the builder if system call fails.
55
+ pub const DEFAULT_CONCURRENCY_LIMIT : usize = 4 ;
56
+
54
57
/// Configuration for a builder running a specific rollup on a specific host
55
58
/// chain.
56
59
#[ derive( Debug , Clone , FromEnv ) ]
@@ -150,7 +153,8 @@ pub struct BuilderConfig {
150
153
/// The max number of simultaneous block simulations to run.
151
154
#[ from_env(
152
155
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
154
158
) ]
155
159
pub concurrency_limit : usize ,
156
160
@@ -276,4 +280,14 @@ impl BuilderConfig {
276
280
pub const fn cfg_env ( & self ) -> SignetCfgEnv {
277
281
SignetCfgEnv { chain_id : self . ru_chain_id }
278
282
}
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
+ }
279
293
}
You can’t perform that action at this time.
0 commit comments