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
159159 compute_stats: bool,
160160 }
161161 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);
163163 let stat_workers = (0..threads)
164164 .map(|_| {
165165 scope.spawn({
@@ -324,12 +324,6 @@ pub fn update( · 158 unmodified lines
324324 }
325325 };
326326 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− }
333327 chunk.push(Task {
334328 parent_commit: first_parent,
335329 commit,
@@ -342,6 +336,12 @@ pub fn update( · 6 unmodified lines
342336 compute_stats: false,
343337 });
344338 }
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+ }
345345 }
346346 Ok(gix::objs::CommitRefIter::from_bytes(obj.data))
347347 }),