Skip to content

Commit 1fe5e0f

Browse files
committed
[WIP] PendingOptimizations: add debug field
1 parent f608e87 commit 1fe5e0f

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎lib/collection/src/operations/types.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ pub struct PendingOptimizations {
319319
pub segments: usize,
320320
/// Total number of points in unoptimized segments.
321321
pub points: usize,
322+
#[serde(skip_serializing_if = "Vec::is_empty")]
323+
#[schemars(skip)]
324+
pub debug: Vec<String>,
322325
}
323326

324327
impl PendingOptimizations {
@@ -327,10 +330,12 @@ impl PendingOptimizations {
327330
optimizations,
328331
segments,
329332
points,
333+
debug,
330334
} = self;
331335
*optimizations += other.optimizations;
332336
*segments += other.segments;
333337
*points += other.points;
338+
debug.extend_from_slice(&other.debug);
334339
}
335340
}
336341

‎lib/collection/src/update_workers/optimization_worker.rs‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::fmt::Write;
12
use std::panic::AssertUnwindSafe;
23
use std::path::Path;
34
use std::sync::Arc;
@@ -270,6 +271,7 @@ impl UpdateWorkers {
270271
let scheduled;
271272
let mut pending_segments = 0;
272273
let mut pending_points = 0;
274+
let mut pending_debug = Vec::new();
273275
{
274276
let segments = segments.read();
275277
let mut planner = OptimizationPlanner::new(
@@ -282,20 +284,26 @@ impl UpdateWorkers {
282284
}
283285
scheduled = planner.into_scheduled();
284286

285-
for (_, segment_ids) in &scheduled {
287+
for (optimizer, segment_ids) in &scheduled {
286288
pending_segments += segment_ids.len();
289+
let mut debug_entry =
290+
format!("{}:", optimizer.as_ref().map_or("?", |opt| opt.name()));
287291
for &segment_id in segment_ids {
288292
if let Some(LockedSegment::Original(segment)) = segments.get(segment_id) {
289-
pending_points += segment.read().total_point_count()
293+
let points = segment.read().total_point_count();
294+
pending_points += points;
295+
write!(debug_entry, " [id={segment_id} points={points}]").unwrap();
290296
}
291297
}
298+
pending_debug.push(debug_entry);
292299
}
293300
}
294301

295302
optimizers_log.lock().pending = PendingOptimizations {
296303
optimizations: scheduled.len(),
297304
segments: pending_segments,
298305
points: pending_points,
306+
debug: pending_debug,
299307
};
300308

301309
for (optimizer, segments_to_merge) in scheduled {

0 commit comments

Comments
 (0)