File tree 3 files changed +14
-7
lines changed
3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -243,6 +243,7 @@ dependencies = [
243
243
" anyhow" ,
244
244
" flate2" ,
245
245
" hex 0.4.2" ,
246
+ " num_cpus" ,
246
247
" rayon" ,
247
248
" serde" ,
248
249
" serde_json" ,
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ tar = "0.4.29"
14
14
sha2 = " 0.9.1"
15
15
rayon = " 1.3.1"
16
16
hex = " 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() {
207
207
// related code in this tool and ./x.py dist hash-and-sign can be removed.
208
208
let legacy = env:: var ( "BUILD_MANIFEST_LEGACY" ) . is_ok ( ) ;
209
209
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" ) ;
217
222
218
223
let mut args = env:: args ( ) . skip ( 1 ) ;
219
224
let input = PathBuf :: from ( args. next ( ) . unwrap ( ) ) ;
You can’t perform that action at this time.
0 commit comments