@@ -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" ) ) ;
0 commit comments