Skip to content

Commit 7368f01

Browse files
committed
Revert "Improve data density visualization by sampling dense chunks (#11766)"
This reverts commit 13470a2.
1 parent 3b4d612 commit 7368f01

2 files changed

Lines changed: 3 additions & 76 deletions

File tree

crates/viewer/re_time_panel/benches/bench_density_graph.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -215,30 +215,6 @@ fn bench_many_chunks(c: &mut Criterion) {
215215
}
216216
}
217217

218-
/// Benchmark that specifically tests the `uniform_sample_events` path.
219-
///
220-
/// This uses large chunks that exceed the individual event rendering threshold,
221-
/// forcing the sampling path to be taken.
222-
fn bench_sampling(c: &mut Criterion) {
223-
let mut group = c.benchmark_group("sampling");
224-
225-
let sizes = [5000, 10000, 20000, 50000, 100000];
226-
for size in sizes {
227-
for max_sampled_events_per_chunk in [0, 4000, 8000] {
228-
let id = format!("{size}/sample_{max_sampled_events_per_chunk}");
229-
230-
let config = DensityGraphBuilderConfig {
231-
max_sampled_events_per_chunk,
232-
..Default::default()
233-
};
234-
235-
group.bench_with_input(id, &single_chunk(size, true), |b, &entry| {
236-
run(b, config, entry);
237-
});
238-
}
239-
}
240-
}
241-
242218
fn main() {
243219
// More noisy results, but benchmark ends a lot sooner.
244220
let mut criterion = Criterion::default()
@@ -250,7 +226,6 @@ fn main() {
250226

251227
bench_single_chunks(&mut criterion);
252228
bench_many_chunks(&mut criterion);
253-
bench_sampling(&mut criterion);
254229

255230
criterion.final_summary();
256231
}

crates/viewer/re_time_panel/src/data_density_graph.rs

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -563,27 +563,10 @@ pub fn build_density_graph<'a>(
563563
};
564564

565565
if should_render_individual_events {
566-
// Render all individual events
567566
for (time, num_events) in chunk.num_events_cumulative_per_unique_time(timeline) {
568-
data.add_chunk_point(time, num_events as f32);
569-
}
570-
} else if config.max_sampled_events_per_chunk > 0 {
571-
let events = chunk.num_events_cumulative_per_unique_time(timeline);
572-
573-
if events.len() > config.max_sampled_events_per_chunk {
574-
// If there's more rows than the configured max, we sample events to get a fast, good enough density estimate.
575-
data.add_uniform_sample_from_chunk(
576-
&events,
577-
config.max_sampled_events_per_chunk,
578-
);
579-
} else {
580-
// No need to sample, we can use all events.
581-
for (time, num_events) in events {
582-
data.add_chunk_point(time, num_events as f32);
583-
}
567+
data.add_chunk_point(time, num_events as usize);
584568
}
585569
} else {
586-
// Fall back to uniform distribution across the entire time range
587570
data.add_chunk_range(time_range, num_events_in_chunk);
588571
}
589572
}
@@ -602,10 +585,6 @@ pub struct DensityGraphBuilderConfig {
602585

603586
/// If an unsorted chunk has fewer events than this we show its individual events.
604587
pub max_events_in_unsorted_chunk: u64,
605-
606-
/// When a chunk is too large to render all events, uniformly sample this many events
607-
/// to create a good enough density estimate instead.
608-
pub max_sampled_events_per_chunk: usize,
609588
}
610589

611590
impl DensityGraphBuilderConfig {
@@ -614,7 +593,6 @@ impl DensityGraphBuilderConfig {
614593
max_total_chunk_events: 0,
615594
max_events_in_unsorted_chunk: 0,
616595
max_events_in_sorted_chunk: 0,
617-
max_sampled_events_per_chunk: 0,
618596
};
619597

620598
/// All sorted chunks will be rendered as individual events,
@@ -623,15 +601,13 @@ impl DensityGraphBuilderConfig {
623601
max_total_chunk_events: u64::MAX,
624602
max_events_in_unsorted_chunk: 0,
625603
max_events_in_sorted_chunk: u64::MAX,
626-
max_sampled_events_per_chunk: 0,
627604
};
628605

629606
/// All chunks will be rendered as individual events.
630607
pub const ALWAYS_SPLIT_ALL_CHUNKS: Self = Self {
631608
max_total_chunk_events: u64::MAX,
632609
max_events_in_unsorted_chunk: u64::MAX,
633610
max_events_in_sorted_chunk: u64::MAX,
634-
max_sampled_events_per_chunk: 0,
635611
};
636612
}
637613

@@ -654,10 +630,6 @@ impl Default for DensityGraphBuilderConfig {
654630

655631
// Processing unsorted events is about 20% slower than sorted events.
656632
max_events_in_unsorted_chunk: 8_000,
657-
658-
// When chunks are too large to render all events, sample this many events uniformly
659-
// to create a good enough density estimate.
660-
max_sampled_events_per_chunk: 8_000,
661633
}
662634
}
663635
}
@@ -720,32 +692,12 @@ impl<'a> DensityGraphBuilder<'a> {
720692
}
721693
}
722694

723-
/// Uniformly sample events using the given sample size.
724-
///
725-
/// Each sampled event's count is reweighted to preserve the total density.
726-
fn add_uniform_sample_from_chunk(&mut self, events: &[(TimeInt, u64)], sample_size: usize) {
727-
re_tracing::profile_function!();
728-
729-
let step = events.len() as f32 / sample_size as f32;
730-
731-
for i in 0..sample_size {
732-
let idx = (i as f32 * step) as usize;
733-
// This means we might miss the last event if rounding down, but that's acceptable.
734-
if let Some(&(time, count)) = events.get(idx) {
735-
// Reweight the count to preserve total density
736-
let weighted_count = count as f32 * step;
737-
738-
self.add_chunk_point(time, weighted_count);
739-
}
740-
}
741-
}
742-
743-
fn add_chunk_point(&mut self, time: TimeInt, weight: f32) {
695+
fn add_chunk_point(&mut self, time: TimeInt, num_events: usize) {
744696
let Some(x) = self.time_ranges_ui.x_from_time_f32(time.into()) else {
745697
return;
746698
};
747699

748-
self.density_graph.add_point(x, weight);
700+
self.density_graph.add_point(x, num_events as _);
749701

750702
if let Some(pointer_pos) = self.pointer_pos
751703
&& self.row_rect.y_range().contains(pointer_pos.y)

0 commit comments

Comments
 (0)