File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -243,6 +243,7 @@ dependencies = [
243243 " anyhow" ,
244244 " flate2" ,
245245 " hex 0.4.2" ,
246+ " num_cpus" ,
246247 " rayon" ,
247248 " serde" ,
248249 " serde_json" ,
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ tar = "0.4.29"
1414sha2 = " 0.9.1"
1515rayon = " 1.3.1"
1616hex = " 0.4.2"
17+ num_cpus = " 1.13.0"
Original file line number Diff line number Diff line change @@ -207,13 +207,18 @@ fn main() {
207207 // related code in this tool and ./x.py dist hash-and-sign can be removed.
208208 let legacy = env:: var ( "BUILD_MANIFEST_LEGACY" ) . is_ok ( ) ;
209209
210- // Avoid overloading the old server in legacy mode.
211- if legacy {
212- rayon:: ThreadPoolBuilder :: new ( )
213- . num_threads ( 1 )
214- . build_global ( )
215- . expect ( "failed to initialize Rayon" ) ;
216- }
210+ let num_threads = if legacy {
211+ // Avoid overloading the old server in legacy mode.
212+ 1
213+ } else if let Ok ( num) = env:: var ( "BUILD_MANIFEST_NUM_THREADS" ) {
214+ num. parse ( ) . expect ( "invalid number for BUILD_MANIFEST_NUM_THREADS" )
215+ } else {
216+ num_cpus:: get ( )
217+ } ;
218+ rayon:: ThreadPoolBuilder :: new ( )
219+ . num_threads ( num_threads)
220+ . build_global ( )
221+ . expect ( "failed to initialize Rayon" ) ;
217222
218223 let mut args = env:: args ( ) . skip ( 1 ) ;
219224 let input = PathBuf :: from ( args. next ( ) . unwrap ( ) ) ;
You can’t perform that action at this time.
0 commit comments