History

fix: chunk-splitting didn't produce chunks correctly and starved threads.

Sebastian Thiel committed 3 years ago

Commit 82a2cdb1 parent d5616b61 file · +7 −7Browse files

Unified · Split

gitoxide-core/src/query/engine/update.rs+7−7
@@ -159,7 +159,7 @@ pub fn update( · 158 unmodified lines
159 compute_stats: bool,159 compute_stats: bool,
160 }160 }
161 let (tx_tree_ids, stat_threads) = {161 let (tx_tree_ids, stat_threads) = {
162 let (tx, rx) = crossbeam_channel::unbounded::<(SequenceId, Vec<Task>)>();162 let (tx, rx) = crossbeam_channel::bounded::<(SequenceId, Vec<Task>)>(threads);
163 let stat_workers = (0..threads)163 let stat_workers = (0..threads)
164 .map(|_| {164 .map(|_| {
165 scope.spawn({165 scope.spawn({
@@ -324,12 +324,6 @@ pub fn update( · 158 unmodified lines
324 }324 }
325 };325 };
326 if let Some((first_parent, commit)) = res {326 if let Some((first_parent, commit)) = res {
327 if chunk.len() == CHUNK_SIZE {
328 tx_tree_ids
329 .send((chunk_id, std::mem::replace(&mut chunk, Vec::with_capacity(CHUNK_SIZE))))
330 .ok();
331 chunk_id += 1;
332 }
333 chunk.push(Task {327 chunk.push(Task {
334 parent_commit: first_parent,328 parent_commit: first_parent,
335 commit,329 commit,
@@ -342,6 +336,12 @@ pub fn update( · 6 unmodified lines
342 compute_stats: false,336 compute_stats: false,
343 });337 });
344 }338 }
339 if chunk.len() == CHUNK_SIZE {
340 tx_tree_ids
341 .send((chunk_id, std::mem::replace(&mut chunk, Vec::with_capacity(CHUNK_SIZE))))
342 .ok();
343 chunk_id += 1;
344 }
345 }345 }
346 Ok(gix::objs::CommitRefIter::from_bytes(obj.data))346 Ok(gix::objs::CommitRefIter::from_bytes(obj.data))
347 }),347 }),