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 ) ]
@@ -157,7 +160,8 @@ pub struct BuilderConfig {
157
160
/// The max number of simultaneous block simulations to run.
158
161
#[ from_env(
159
162
var = "CONCURRENCY_LIMIT" ,
160
- desc = "The max number of simultaneous block simulations to run"
163
+ desc = "The max number of simultaneous block simulations to run" ,
164
+ optional
161
165
) ]
162
166
pub concurrency_limit : usize ,
163
167
@@ -285,4 +289,14 @@ impl BuilderConfig {
285
289
pub const fn cfg_env ( & self ) -> SignetCfgEnv {
286
290
SignetCfgEnv { chain_id : self . ru_chain_id }
287
291
}
292
+
293
+ /// Get the concurrency limit for the current system.
294
+ pub fn concurrency_limit ( & self ) -> usize {
295
+ if self . concurrency_limit == 0 {
296
+ std:: thread:: available_parallelism ( )
297
+ . map ( |p| p. get ( ) )
298
+ . unwrap_or ( DEFAULT_CONCURRENCY_LIMIT ) ;
299
+ }
300
+ self . concurrency_limit
301
+ }
288
302
}
You can’t perform that action at this time.
0 commit comments