Skip to content

Commit 0cefb55

Browse files
committed
adapt to changes in git-features::fs.
We only use parallel traversal where it matters most, namely loose object traversal which can be many objects in up to 256 folders. Being able to parallelize among them will be a noticable speedup well worth the cost (presumably). Ref traversals are single-threaded as we expect most refs in packed-refs anyway. Furthermore we can now consider parallel traversal safe as we don't use the global rayon pool anymore, something that can break any parallel iteration (and just a version of `jwalk` earlier it would deadlock).
1 parent c7566e4 commit 0cefb55

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

git-odb/src/store_impls/loose/find.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ impl Store {
4949
mut candidates: Option<&mut HashSet<git_hash::ObjectId>>,
5050
) -> Result<Option<crate::find::PrefixLookupResult>, crate::loose::iter::Error> {
5151
let single_directory_iter = crate::loose::Iter {
52-
inner: git_features::fs::walkdir_new(&self.path.join(prefix.as_oid().to_hex_with_len(2).to_string()))
53-
.min_depth(1)
54-
.max_depth(1)
55-
.follow_links(false)
56-
.into_iter(),
52+
inner: git_features::fs::walkdir_new(
53+
&self.path.join(prefix.as_oid().to_hex_with_len(2).to_string()),
54+
git_features::fs::walkdir::Parallelism::Serial,
55+
)
56+
.min_depth(1)
57+
.max_depth(1)
58+
.follow_links(false)
59+
.into_iter(),
5760
hash_hex_len: prefix.as_oid().kind().len_in_hex(),
5861
};
5962
let mut candidate = None;

git-odb/src/store_impls/loose/iter.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,16 @@ impl loose::Store {
6565
/// needed if iterators need to be implemented by hand in the absence of generators.
6666
pub fn iter(&self) -> loose::Iter {
6767
loose::Iter {
68-
inner: fs::walkdir_new(&self.path)
69-
.min_depth(2)
70-
.max_depth(3)
71-
.follow_links(false)
72-
.into_iter(),
68+
inner: fs::walkdir_new(
69+
&self.path,
70+
fs::walkdir::Parallelism::ThreadPoolPerTraversal {
71+
thread_name: "git_odb::loose::Store::iter: fs-walk",
72+
},
73+
)
74+
.min_depth(2)
75+
.max_depth(3)
76+
.follow_links(false)
77+
.into_iter(),
7378
hash_hex_len: self.object_hash.len_in_hex(),
7479
}
7580
}

git-ref/src/store/file/loose/iter.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ impl SortedLoosePaths {
1818
SortedLoosePaths {
1919
base: base.into(),
2020
filename_prefix,
21-
file_walk: path
22-
.is_dir()
23-
.then(|| git_features::fs::walkdir_sorted_new(path).into_iter()),
21+
file_walk: path.is_dir().then(|| {
22+
// serial iteration as we expect most refs in packed-refs anyway.
23+
git_features::fs::walkdir_sorted_new(path, git_features::fs::walkdir::Parallelism::Serial).into_iter()
24+
}),
2425
}
2526
}
2627
}

git-repository/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ serde1 = [ "serde",
6464

6565
## Activate other features that maximize performance, like usage of threads, `zlib-ng` and access to caching in object databases.
6666
## Note that some platforms might suffer from compile failures, which is when `max-performance-safe` should be used.
67-
max-performance = [ "git-features/zlib-ng-compat", "fast-sha1", "max-performance-safe", "git-features/fs-walkdir-parallel" ]
67+
max-performance = [ "git-features/zlib-ng-compat", "fast-sha1", "max-performance-safe" ]
6868

6969
## If enabled, use assembly versions of sha1 on supported platforms.
7070
## This might cause compile failures as well which is why it can be turned off separately.
@@ -75,7 +75,8 @@ fast-sha1 = [ "git-features/fast-sha1" ]
7575
max-performance-safe = [
7676
"git-features/parallel",
7777
"git-pack/pack-cache-lru-static",
78-
"git-pack/pack-cache-lru-dynamic"
78+
"git-pack/pack-cache-lru-dynamic",
79+
"git-features/fs-walkdir-parallel"
7980
]
8081
## Print debugging information about usage of object database caches, useful for tuning cache sizes.
8182
cache-efficiency-debug = ["git-features/cache-efficiency-debug"]

0 commit comments

Comments
 (0)