Skip to content

Commit d67551d

Browse files
committed
Use unlimited parallelism for jwalk to have a better comparison.
Before replacing it with `moonwalk`
1 parent 0b59288 commit d67551d

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

Diff for: gitoxide-core/src/organize.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn find_git_repository_workdirs<P: Progress>(
1616
root: impl AsRef<Path>,
1717
mut progress: P,
1818
debug: bool,
19+
threads: Option<usize>,
1920
) -> impl Iterator<Item = (PathBuf, gix::Kind)>
2021
where
2122
P::SubProgress: Sync,
@@ -54,14 +55,8 @@ where
5455
let walk = jwalk::WalkDirGeneric::<((), State)>::new(root)
5556
.follow_links(false)
5657
.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)));
6560

6661
walk.process_read_dir(move |_depth, path, _read_dir_state, siblings| {
6762
if debug {
@@ -215,12 +210,13 @@ pub fn discover<P: Progress>(
215210
mut out: impl std::io::Write,
216211
mut progress: P,
217212
debug: bool,
213+
threads: Option<usize>,
218214
) -> anyhow::Result<()>
219215
where
220216
<P::SubProgress as Progress>::SubProgress: Sync,
221217
{
222218
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)
224220
{
225221
writeln!(&mut out, "{}", git_workdir.display())?;
226222
}
@@ -232,14 +228,15 @@ pub fn run<P: Progress>(
232228
source_dir: impl AsRef<Path>,
233229
destination: impl AsRef<Path>,
234230
mut progress: P,
231+
threads: Option<usize>,
235232
) -> anyhow::Result<()>
236233
where
237234
<P::SubProgress as Progress>::SubProgress: Sync,
238235
{
239236
let mut num_errors = 0usize;
240237
let destination = destination.as_ref().canonicalize()?;
241238
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)
243240
{
244241
if let Err(err) = handle(mode, kind, &path_to_move, &destination, &mut progress) {
245242
progress.fail(format!(

Diff for: src/porcelain/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub fn main() -> Result<()> {
128128
out,
129129
progress,
130130
debug,
131+
threads,
131132
)
132133
},
133134
)
@@ -154,6 +155,7 @@ pub fn main() -> Result<()> {
154155
repository_source.unwrap_or_else(|| [std::path::Component::CurDir].iter().collect()),
155156
destination_directory.unwrap_or_else(|| [std::path::Component::CurDir].iter().collect()),
156157
progress,
158+
threads,
157159
)
158160
},
159161
)

0 commit comments

Comments
 (0)