Skip to content

Commit 584350a

Browse files
committed
Revert "Less memory for look up mode, faster start" - too slow
Iterating in order of the pack uses the cache way better, which gives a huge speedup. This reverts commit 395c7e7.
1 parent 7d6abef commit 584350a

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

git-odb/src/pack/index/access.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl index::File {
126126
None
127127
}
128128

129-
pub fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = Entry> + 'a + Send> {
129+
pub fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = Entry> + 'a> {
130130
match self.kind {
131131
index::Kind::V2 => Box::new(self.iter_v2()),
132132
index::Kind::V1 => Box::new(self.iter_v1()),

git-odb/src/pack/index/traverse/lookup.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ impl index::File {
2727
&mut <<P as Progress>::SubProgress as Progress>::SubProgress,
2828
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>,
2929
{
30-
let (chunk_size, thread_limit, _) =
31-
parallel::optimize_chunk_size_and_thread_limit(1000, Some(self.num_objects as usize), thread_limit, None);
32-
let there_are_enough_entries_to_process = || self.num_objects > 10_000;
30+
let index_entries =
31+
util::index_entries_sorted_by_offset_ascending(self, root.add_child("collecting sorted index"));
32+
33+
let (chunk_size, thread_limit, available_cores) =
34+
parallel::optimize_chunk_size_and_thread_limit(1000, Some(index_entries.len()), thread_limit, None);
35+
let there_are_enough_entries_to_process = || index_entries.len() > chunk_size * available_cores;
36+
let input_chunks = index_entries.chunks(chunk_size.max(chunk_size));
3337
let reduce_progress = parking_lot::Mutex::new({
3438
let mut p = root.add_child("Traversing");
3539
p.init(Some(self.num_objects()), Some("objects"));
@@ -46,13 +50,10 @@ impl index::File {
4650

4751
in_parallel_if(
4852
there_are_enough_entries_to_process,
49-
util::Chunks {
50-
iter: self.iter(),
51-
size: chunk_size,
52-
},
53+
input_chunks,
5354
thread_limit,
5455
state_per_thread,
55-
|entries: Vec<index::Entry>,
56+
|entries: &[index::Entry],
5657
(cache, ref mut processor, buf, progress)|
5758
-> Result<Vec<decode::Outcome>, Error> {
5859
progress.init(Some(entries.len() as u32), Some("entries"));

src/plumbing/lean.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ mod options {
130130
/// owned objects, causing plenty of allocation to occour.
131131
pub re_encode: bool,
132132

133-
#[argh(option, short = 'a')]
133+
#[argh(option)]
134134
/// the algorithm used to verify the pack. They differ in costs.
135135
///
136136
/// Possible values are "less-time" and "less-memory". Default is "less-memory".

tasks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* [x] figure out why resolving the linux pack is so slow and fix it
2626
* [x] Allow to provide a pre-resolve phase to initialize the resolver
2727
* [x] Use Tree in verify impl
28-
* [x] fix lookup todos
28+
* [x] ~~fix lookup todos~~ - it's nearly twice as slow
2929
* [ ] per-object counts for statistics (and use that to optimize order when matching on object types)
3030
* [ ] nicer errors with descriptive messages
3131
* [ ] handle ctrl+c similarly to the pretty version to prevent leakage (or find a way to use

0 commit comments

Comments
 (0)