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

Primary caching 6: TextLogs & TimeSeries #4698

Merged
merged 6 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/re_query_cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub use self::query::{

pub(crate) use self::cache::LatestAtCache;

pub use re_query::{QueryError, Result}; // convenience

// TODO(cmc): Supporting N>1 generically is quite painful due to limitations in declarative macros,
// not that we care at the moment.
seq_macro::seq!(NUM_COMP in 0..10 { paste::paste! {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_text_log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ re_data_ui.workspace = true
re_entity_db.workspace = true
re_log.workspace = true
re_log_types.workspace = true
re_query.workspace = true
re_query_cache.workspace = true
re_renderer.workspace = true
re_tracing.workspace = true
re_types.workspace = true
Expand Down
42 changes: 20 additions & 22 deletions crates/re_space_view_text_log/src/visualizer_system.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use re_data_store::TimeRange;
use re_entity_db::EntityPath;
use re_log_types::RowId;
use re_query::range_archetype;
use re_log_types::{RowId, TimeInt};
use re_types::{
archetypes::TextLog,
components::{Color, Text, TextLogLevel},
Expand Down Expand Up @@ -66,28 +65,27 @@ impl VisualizerSystem for TextLogSystem {
let timeline_query =
re_data_store::RangeQuery::new(query.timeline, TimeRange::EVERYTHING);

let arch_views = range_archetype::<TextLog, { TextLog::NUM_COMPONENTS }>(
re_query_cache::query_archetype_pov1_comp2::<TextLog, Text, TextLogLevel, Color, _>(
ctx.app_options.experimental_primary_caching_series,
store,
&timeline_query,
&timeline_query.clone().into(),
&data_result.entity_path,
);

for (time, arch_view) in arch_views {
let bodies = arch_view.iter_required_component::<Text>()?;
let levels = arch_view.iter_optional_component::<TextLogLevel>()?;
let colors = arch_view.iter_optional_component::<Color>()?;

for (body, level, color) in itertools::izip!(bodies, levels, colors) {
self.entries.push(Entry {
row_id: arch_view.primary_row_id(),
entity_path: data_result.entity_path.clone(),
time: time.map(|time| time.as_i64()),
color,
body,
level,
});
}
}
|((time, row_id), _, bodies, levels, colors)| {
for (body, level, color) in
itertools::izip!(bodies.iter(), levels.iter(), colors.iter())
{
self.entries.push(Entry {
row_id,
entity_path: data_result.entity_path.clone(),
// TODO(cmc): real support for timeless data in caches.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time: (time != TimeInt::MIN).then(|| time.as_i64()),
color: *color,
body: body.clone(),
level: level.clone(),
});
}
},
)?;
}

{
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_time_series/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ all-features = true
re_data_store.workspace = true
re_format.workspace = true
re_log_types.workspace = true
re_query.workspace = true
re_query_cache.workspace = true
re_renderer.workspace = true
re_space_view.workspace = true
re_tracing.workspace = true
Expand Down
78 changes: 42 additions & 36 deletions crates/re_space_view_time_series/src/visualizer_system.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use re_data_store::TimeRange;
use re_query::{range_archetype, QueryError};
use re_query_cache::QueryError;
use re_types::{
archetypes::TimeSeriesScalar,
components::{Color, Radius, Scalar, ScalarScattering, Text},
Expand Down Expand Up @@ -153,42 +153,48 @@ impl TimeSeriesSystem {

let query = re_data_store::RangeQuery::new(query.timeline, TimeRange::new(from, to));

let arch_views = range_archetype::<
re_query_cache::query_archetype_pov1_comp4::<
TimeSeriesScalar,
{ TimeSeriesScalar::NUM_COMPONENTS },
>(store, &query, &data_result.entity_path);

for (time, arch_view) in arch_views {
let Some(time) = time else {
continue;
}; // scalars cannot be timeless

for (scalar, scattered, color, radius, label) in itertools::izip!(
arch_view.iter_required_component::<Scalar>()?,
arch_view.iter_optional_component::<ScalarScattering>()?,
arch_view.iter_optional_component::<Color>()?,
arch_view.iter_optional_component::<Radius>()?,
arch_view.iter_optional_component::<Text>()?,
) {
let color = annotation_info.color(color.map(|c| c.to_array()), default_color);
let label = annotation_info.label(label.as_ref().map(|l| l.as_str()));

const DEFAULT_RADIUS: f32 = 0.75;

points.push(PlotPoint {
time: time.as_i64(),
value: scalar.0,
attrs: PlotPointAttrs {
label,
color,
radius: radius.map_or(DEFAULT_RADIUS, |r| r.0),
scattered: scattered.map_or(false, |s| s.0),
},
});
}
}

points.sort_by_key(|s| s.time);
Scalar,
ScalarScattering,
Color,
Radius,
Text,
_,
>(
ctx.app_options.experimental_primary_caching_series,
store,
&query.clone().into(),
&data_result.entity_path,
|((time, _row_id), _, scalars, scatterings, colors, radii, labels)| {
re_tracing::profile_scope!("primary");

for (scalar, scattered, color, radius, label) in itertools::izip!(
scalars.iter(),
scatterings.iter(),
colors.iter(),
radii.iter(),
labels.iter()
) {
let color =
annotation_info.color(color.map(|c| c.to_array()), default_color);
let label = annotation_info.label(label.as_ref().map(|l| l.as_str()));

const DEFAULT_RADIUS: f32 = 0.75;

points.push(PlotPoint {
time: time.as_i64(),
value: scalar.0,
attrs: PlotPointAttrs {
label,
color,
radius: radius.map_or(DEFAULT_RADIUS, |r| r.0),
scattered: scattered.map_or(false, |s| s.0),
},
});
}
},
)?;

if points.is_empty() {
continue;
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/definitions/rerun/archetypes/text_log.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ table TextLog (
level: rerun.components.TextLogLevel ("attr.rerun.component_recommended", nullable, order: 200);

/// Optional color to use for the log line in the Rerun Viewer.
color: rerun.components.Color (nullable, order: 300);
color: rerun.components.Color ("attr.rerun.component_optional", nullable, order: 300);
teh-cmc marked this conversation as resolved.
Show resolved Hide resolved
}
14 changes: 10 additions & 4 deletions crates/re_types/src/archetypes/text_log.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions crates/re_viewer/src/ui/rerun_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ fn experimental_feature_ui(
)
.on_hover_text("Toggle primary caching for the 2D & 3D point cloud space views.");

re_ui
.checkbox(
ui,
&mut app_options.experimental_primary_caching_series,
"Primary caching: TextLogs & TimeSeries",
)
.on_hover_text("Toggle primary caching for the time series & text logs space views.");

re_ui
.checkbox(
ui,
Expand Down
7 changes: 7 additions & 0 deletions crates/re_viewer_context/src/app_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub struct AppOptions {
/// Toggle primary caching for the 2D & 3D point cloud space views.
pub experimental_primary_caching_point_clouds: bool,

/// Toggle primary caching for the time series & text logs space views.
pub experimental_primary_caching_series: bool,

/// Displays an overlay for debugging picking.
pub show_picking_debug_overlay: bool,

Expand Down Expand Up @@ -61,6 +64,10 @@ impl Default for AppOptions {
// merged in.
experimental_primary_caching_point_clouds: false,

// TODO(cmc): default to true for debug/rerun-workspace once minimal features have been
// merged in.
Comment on lines +67 to +68
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be defaulted to true later this week when cached range support starts becoming a thing.

experimental_primary_caching_series: false,

show_picking_debug_overlay: false,

show_blueprint_in_timeline: false,
Expand Down
2 changes: 2 additions & 0 deletions docs/content/reference/types/archetypes/text_log.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading