File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -122,8 +122,8 @@ pub fn format(build: &Build, check: bool) {
122122 WalkBuilder :: new ( src. clone ( ) ) . types ( matcher) . overrides ( ignore_fmt) . build_parallel ( ) ;
123123
124124 // there is a lot of blocking involved in spawning a child process and reading files to format.
125- // spawn more processes than available cores to keep the CPU busy
126- let max_processes = num_cpus :: get ( ) * 2 ;
125+ // spawn more processes than available concurrency to keep the CPU busy
126+ let max_processes = build . jobs ( ) as usize * 2 ;
127127
128128 // spawn child processes on a separate thread so we can batch entries we have received from ignore
129129 let thread = std:: thread:: spawn ( move || {
@@ -135,7 +135,7 @@ pub fn format(build: &Build, check: bool) {
135135 let child = rustfmt ( & src, & rustfmt_path, paths. as_slice ( ) , check) ;
136136 children. push_back ( child) ;
137137
138- if children. len ( ) > max_processes {
138+ if children. len ( ) >= max_processes {
139139 // await oldest child
140140 children. pop_front ( ) . unwrap ( ) ( ) ;
141141 }
You can’t perform that action at this time.
0 commit comments