Skip to content

Commit

Permalink
toggle latest-at and/or range queries as a whole
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jan 11, 2024
1 parent e547ef4 commit b223a90
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 29 deletions.
38 changes: 28 additions & 10 deletions crates/re_query_cache/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ seq!(NUM_COMP in 0..10 {
/// and no optional components.
///
/// Alias for [`query_archetype_with_history_pov1_comp0`].
#[allow(clippy::too_many_arguments)]
#[inline]
pub fn query_archetype_with_history_pov1<'a, A, R1, F>(
cached: bool,
cached_latest_at: bool,
cached_range: bool,
store: &'a DataStore,
timeline: &'a Timeline,
time: &'a TimeInt,
Expand All @@ -211,7 +213,14 @@ where
),
{
query_archetype_with_history_pov1_comp0::<A, R1, F>(
cached, store, timeline, time, history, ent_path, f,
cached_latest_at,
cached_range,
store,
timeline,
time,
history,
ent_path,
f,
)
}

Expand All @@ -221,8 +230,10 @@ macro_rules! impl_query_archetype_with_history {
(for N=$N:expr, M=$M:expr => povs=[$($pov:ident)+] comps=[$($comp:ident)*]) => { paste! {
#[doc = "Cached implementation of [`re_query::query_archetype_with_history`] for `" $N "` point-of-view"]
#[doc = "components and `" $M "` optional components."]
#[allow(clippy::too_many_arguments)]
pub fn [<query_archetype_with_history_pov$N _comp$M>]<'a, A, $($pov,)+ $($comp,)* F>(
cached: bool,
cached_latest_at: bool,
cached_range: bool,
store: &'a DataStore,
timeline: &'a Timeline,
time: &'a TimeInt,
Expand All @@ -243,32 +254,39 @@ macro_rules! impl_query_archetype_with_history {
),
),
{
// NOTE: not `profile_function!` because we want them merged together.
re_tracing::profile_scope!(
"query_archetype_with_history",
format!("cached={cached} arch={} pov={} comp={}", A::name(), $N, $M)
);

let visible_history = match timeline.typ() {
re_log_types::TimeType::Time => history.nanos,
re_log_types::TimeType::Sequence => history.sequences,
};

if !history.enabled || visible_history == VisibleHistory::OFF {
// NOTE: not `profile_function!` because we want them merged together.
re_tracing::profile_scope!(
"query_archetype_with_history",
format!("cached={cached_latest_at} arch={} pov={} comp={}", A::name(), $N, $M)
);

let query = LatestAtQuery::new(*timeline, *time);
$crate::[<query_archetype_pov$N _comp$M>]::<A, $($pov,)+ $($comp,)* _>(
cached,
cached_latest_at,
store,
&query.clone().into(),
ent_path,
f,
)
} else {
// NOTE: not `profile_function!` because we want them merged together.
re_tracing::profile_scope!(
"query_archetype_with_history",
format!("cached={cached_range} arch={} pov={} comp={}", A::name(), $N, $M)
);

let min_time = visible_history.from(*time);
let max_time = visible_history.to(*time);
let query = RangeQuery::new(*timeline, TimeRange::new(min_time, max_time));
$crate::[<query_archetype_pov$N _comp$M>]::<A, $($pov,)+ $($comp,)* _>(
cached,
cached_range,
store,
&query.clone().into(),
ent_path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ macro_rules! impl_process_archetype {
query: &ViewQuery<'_>,
view_ctx: &ViewContextCollection,
default_depth_offset: DepthOffset,
cached: bool,
mut f: F,
) -> Result<(), SpaceViewSystemExecutionError>
where
Expand All @@ -146,7 +145,7 @@ macro_rules! impl_process_archetype {
// NOTE: not `profile_function!` because we want them merged together.
re_tracing::profile_scope!(
"process_archetype",
format!("cached={cached} arch={} pov={} comp={}", A::name(), $N, $M)
format!("arch={} pov={} comp={}", A::name(), $N, $M)
);

let transforms = view_ctx.get::<TransformContext>()?;
Expand Down Expand Up @@ -185,7 +184,8 @@ macro_rules! impl_process_archetype {
};

::re_query_cache::[<query_archetype_with_history_pov$N _comp$M>]::<A, $($pov,)+ $($comp,)* _>(
cached,
ctx.app_options.experimental_primary_caching_latest_at,
ctx.app_options.experimental_primary_caching_range,
ctx.entity_db.store(),
&query.timeline,
&query.latest_at,
Expand Down
1 change: 0 additions & 1 deletion crates/re_space_view_spatial/src/visualizers/points2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ impl VisualizerSystem for Points2DVisualizer {
query,
view_ctx,
view_ctx.get::<EntityDepthOffsets>()?.points,
ctx.app_options.experimental_primary_caching_point_clouds,
|_ctx,
ent_path,
_ent_props,
Expand Down
1 change: 0 additions & 1 deletion crates/re_space_view_spatial/src/visualizers/points3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ impl VisualizerSystem for Points3DVisualizer {
query,
view_ctx,
view_ctx.get::<EntityDepthOffsets>()?.points,
ctx.app_options.experimental_primary_caching_point_clouds,
|_ctx,
ent_path,
_ent_props,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_text_log/src/visualizer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl VisualizerSystem for TextLogSystem {
re_data_store::RangeQuery::new(query.timeline, TimeRange::EVERYTHING);

re_query_cache::query_archetype_pov1_comp2::<TextLog, Text, TextLogLevel, Color, _>(
ctx.app_options.experimental_primary_caching_series,
ctx.app_options.experimental_primary_caching_range,
store,
&timeline_query.clone().into(),
&data_result.entity_path,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_time_series/src/visualizer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl TimeSeriesSystem {
Text,
_,
>(
ctx.app_options.experimental_primary_caching_series,
ctx.app_options.experimental_primary_caching_range,
store,
&query.clone().into(),
&data_result.entity_path,
Expand Down
12 changes: 6 additions & 6 deletions crates/re_viewer/src/ui/rerun_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,18 @@ fn experimental_feature_ui(
re_ui
.checkbox(
ui,
&mut app_options.experimental_primary_caching_point_clouds,
"Primary caching: 2D & 3D point clouds",
&mut app_options.experimental_primary_caching_latest_at,
"Primary caching: latest-at queries",
)
.on_hover_text("Toggle primary caching for the 2D & 3D point cloud space views.");
.on_hover_text("Toggle primary caching for latest-at queries.\nApplies to the 2D/3D point cloud, text log and time series space views.");

re_ui
.checkbox(
ui,
&mut app_options.experimental_primary_caching_series,
"Primary caching: TextLogs & TimeSeries",
&mut app_options.experimental_primary_caching_range,
"Primary caching: range queries",
)
.on_hover_text("Toggle primary caching for the time series & text logs space views.");
.on_hover_text("Toggle primary caching for range queries.\nApplies to the 2D/3D point cloud, text log and time series space views.");

re_ui
.checkbox(
Expand Down
16 changes: 10 additions & 6 deletions crates/re_viewer_context/src/app_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ pub struct AppOptions {
/// Enable the experimental support for the container addition workflow.
pub experimental_additive_workflow: bool,

/// Toggle primary caching for the 2D & 3D point cloud space views.
pub experimental_primary_caching_point_clouds: bool,
/// Toggle primary caching for latest-at queries.
///
/// Applies to the 2D/3D point cloud, text log and time series space views.
pub experimental_primary_caching_latest_at: bool,

/// Toggle primary caching for the time series & text logs space views.
pub experimental_primary_caching_series: bool,
/// Toggle primary caching for range queries.
///
/// Applies to the 2D/3D point cloud, text log and time series space views.
pub experimental_primary_caching_range: bool,

/// Displays an overlay for debugging picking.
pub show_picking_debug_overlay: bool,
Expand Down Expand Up @@ -60,8 +64,8 @@ impl Default for AppOptions {

experimental_additive_workflow: cfg!(debug_assertions),

experimental_primary_caching_point_clouds: true,
experimental_primary_caching_series: true,
experimental_primary_caching_latest_at: true,
experimental_primary_caching_range: false,

show_picking_debug_overlay: false,

Expand Down

0 comments on commit b223a90

Please sign in to comment.