@@ -16,6 +16,7 @@ fn find_git_repository_workdirs<P: Progress>(
16
16
root : impl AsRef < Path > ,
17
17
mut progress : P ,
18
18
debug : bool ,
19
+ threads : Option < usize > ,
19
20
) -> impl Iterator < Item = ( PathBuf , gix:: Kind ) >
20
21
where
21
22
P :: SubProgress : Sync ,
54
55
let walk = jwalk:: WalkDirGeneric :: < ( ( ) , State ) > :: new ( root)
55
56
. follow_links ( false )
56
57
. sort ( true )
57
- . skip_hidden ( false ) ;
58
-
59
- // On macos with apple silicon, the IO subsystem is entirely different and one thread can mostly max it out.
60
- // Thus using more threads just burns energy unnecessarily.
61
- // It's notable that `du` is very fast even on a single core and more power efficient than dua with a single core.
62
- // The default of '4' seems related to the amount of performance cores present in the system.
63
- #[ cfg( all( target_os = "macos" , target_arch = "aarch64" ) ) ]
64
- let walk = walk. parallelism ( jwalk:: Parallelism :: RayonNewPool ( 4 ) ) ;
58
+ . skip_hidden ( false )
59
+ . parallelism ( jwalk:: Parallelism :: RayonNewPool ( threads. unwrap_or ( 0 ) ) ) ;
65
60
66
61
walk. process_read_dir ( move |_depth, path, _read_dir_state, siblings| {
67
62
if debug {
@@ -215,12 +210,13 @@ pub fn discover<P: Progress>(
215
210
mut out : impl std:: io:: Write ,
216
211
mut progress : P ,
217
212
debug : bool ,
213
+ threads : Option < usize > ,
218
214
) -> anyhow:: Result < ( ) >
219
215
where
220
216
<P :: SubProgress as Progress >:: SubProgress : Sync ,
221
217
{
222
218
for ( git_workdir, _kind) in
223
- find_git_repository_workdirs ( source_dir, progress. add_child ( "Searching repositories" ) , debug)
219
+ find_git_repository_workdirs ( source_dir, progress. add_child ( "Searching repositories" ) , debug, threads )
224
220
{
225
221
writeln ! ( & mut out, "{}" , git_workdir. display( ) ) ?;
226
222
}
@@ -232,14 +228,15 @@ pub fn run<P: Progress>(
232
228
source_dir : impl AsRef < Path > ,
233
229
destination : impl AsRef < Path > ,
234
230
mut progress : P ,
231
+ threads : Option < usize > ,
235
232
) -> anyhow:: Result < ( ) >
236
233
where
237
234
<P :: SubProgress as Progress >:: SubProgress : Sync ,
238
235
{
239
236
let mut num_errors = 0usize ;
240
237
let destination = destination. as_ref ( ) . canonicalize ( ) ?;
241
238
for ( path_to_move, kind) in
242
- find_git_repository_workdirs ( source_dir, progress. add_child ( "Searching repositories" ) , false )
239
+ find_git_repository_workdirs ( source_dir, progress. add_child ( "Searching repositories" ) , false , threads )
243
240
{
244
241
if let Err ( err) = handle ( mode, kind, & path_to_move, & destination, & mut progress) {
245
242
progress. fail ( format ! (
0 commit comments