Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize out unnecessary sorts in line series visualizer #7129

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use itertools::Itertools;

use re_log_types::TimeInt;
use re_space_view::range_with_blueprint_resolved_data;
use re_types::archetypes;
use re_types::components::AggregationPolicy;
Expand Down Expand Up @@ -375,9 +376,24 @@ impl SeriesLineSystem {
// This is fine, because we know there's no `TypedFallbackProvider`, but wrong if one were to be added.
.unwrap_or_default();

// NOTE: The chunks themselves are already sorted as best as possible (hint: overlap)
// by the query engine.
let all_chunks_sorted_and_not_overlapped =
all_scalar_chunks.iter().tuple_windows().all(|(lhs, rhs)| {
let lhs_time_max = lhs
.timelines()
.get(&query.timeline())
.map_or(TimeInt::MAX, |time_column| time_column.time_range().max());
let rhs_time_min = rhs
.timelines()
.get(&query.timeline())
.map_or(TimeInt::MIN, |time_column| time_column.time_range().min());
lhs_time_max <= rhs_time_min
});

// This is _almost_ sorted already: all the individual chunks are sorted, but we still
// have to deal with overlap chunks.
{
if !all_chunks_sorted_and_not_overlapped {
re_tracing::profile_scope!("sort");
points.sort_by_key(|p| p.time);
}
Expand Down
Loading