@@ -170,20 +170,31 @@ impl<E: MinimizerBucketingExecutorFactory + Sync + Send + 'static> AsyncExecutor
170170 buckets[ bucket_index] . chunks . sort_by_cached_key ( |c| {
171171 let file_size = MemoryFs :: get_file_size ( c) . unwrap ( ) ;
172172 total_size += file_size;
173- Reverse ( file_size)
173+ let is_compacted = c
174+ . file_name ( )
175+ . unwrap ( )
176+ . to_str ( )
177+ . unwrap ( )
178+ . contains ( "compacted" ) ;
179+ Reverse ( ( is_compacted, file_size) )
174180 } ) ;
175181
176182 let mut chosen_size = 0 ;
177183
178184 // Choose the buckets to compact, taking all the buckets that strictly do not exceed half of the total buckets size.
179185 // this allows to keep a linear time complexity
180186
187+ // println!(
188+ // "Buckets tot size: {} tbc: {:?}",
189+ // total_size, buckets[bucket_index].chunks
190+ // );
191+
181192 let mut last = buckets[ bucket_index] . chunks . pop ( ) . unwrap ( ) ;
182193 let mut last_size = MemoryFs :: get_file_size ( & last) . unwrap ( ) ;
183194
184195 // Choose buckets until one of two conditions is met:
185196 // 1. The next bucket would add up to a size greater than half ot the total size
186- // 2. Two buckets were already selected and the number of sequences is greater than the maximum amount
197+ // 2. Four buckets were already selected and the number of sequences is greater than the maximum amount
187198 // The second condition is checked below, after the processing of each bucket
188199 while chosen_size + last_size < total_size / 2 {
189200 chosen_size += last_size;
@@ -201,6 +212,9 @@ impl<E: MinimizerBucketingExecutorFactory + Sync + Send + 'static> AsyncExecutor
201212 buckets[ bucket_index]
202213 . chunks
203214 . extend ( chosen_buckets. drain ( ..) ) ;
215+ }
216+
217+ if chosen_buckets. is_empty ( ) {
204218 continue ;
205219 }
206220
@@ -295,7 +309,7 @@ impl<E: MinimizerBucketingExecutorFactory + Sync + Send + 'static> AsyncExecutor
295309
296310 // Do not process more buckets if it will increase the maximum number of allowed sequences
297311 if !global_params. common . is_active . load ( Ordering :: Relaxed )
298- || processed_buckets >= 2 && total_sequences > MAXIMUM_SEQUENCES
312+ || processed_buckets >= 4 && total_sequences > MAXIMUM_SEQUENCES
299313 {
300314 break ;
301315 }
0 commit comments