Skip to content

Improve transform performance (by caching affine transforms resulting from transform components) #8691

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

Merged
merged 31 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b89680d
first somewhat working version of transform cache
Wumpf Dec 12, 2024
712a0f0
better structure: less lookups to build up transform tree
Wumpf Dec 13, 2024
43fcc3a
use transform cache for pose transforms as well
Wumpf Dec 13, 2024
4723587
move pinhole to transform cache
Wumpf Dec 13, 2024
eb4bd9f
some cleanup
Wumpf Dec 13, 2024
68a289b
better commentary on TransformContext, fix for missing transforms, re…
Wumpf Jan 10, 2025
5d121a8
use entity path hash in TransformContext instead of stored paths
Wumpf Jan 10, 2025
1d84726
some notes for next-week me
Wumpf Jan 10, 2025
3452e20
transform cache now records updates and applies them instead of popul…
Wumpf Jan 13, 2025
5d7c31f
improve "aspect" determiniation
Wumpf Jan 13, 2025
10e0369
implement cache invalidation
Wumpf Jan 13, 2025
6c92487
renamed transform context to transform tree context
Wumpf Jan 13, 2025
b719f5f
test wip (why is it failing?)
Wumpf Jan 13, 2025
fbba77c
Fix not all events being processed
Wumpf Jan 14, 2025
2e2545f
add more tests, fix clears, improve interface
Wumpf Jan 14, 2025
71937de
add test for out of order updates on transform cache
Wumpf Jan 14, 2025
a254f80
typos
Wumpf Jan 14, 2025
a83035e
address some doc & style related comments
Wumpf Jan 15, 2025
625c584
it ain't no queue!
Wumpf Jan 15, 2025
cb30d71
more docs, Box pose & pinhole to save some memory
Wumpf Jan 15, 2025
6950a70
Move default view coordinates constant to Pinhole
Wumpf Jan 15, 2025
fb4efad
more comment & structure improvements
Wumpf Jan 15, 2025
e330fe9
fix wrong subscriber name
Wumpf Jan 15, 2025
f40d443
more comment & style
Wumpf Jan 15, 2025
c517a85
consistently handle invalid transforms
Wumpf Jan 15, 2025
f4155af
collect instead of loop
Wumpf Jan 15, 2025
5d8fdaf
add garbage collection to transform cache
Wumpf Jan 15, 2025
bbf8290
reference ticket for reporting invalid transforms
Wumpf Jan 15, 2025
0d499f8
warn for non-mono transform lists
Wumpf Jan 15, 2025
4aed794
doc string fix
Wumpf Jan 15, 2025
3e21fdd
undo incorrect comment change
Wumpf Jan 15, 2025
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 crates/store/re_chunk/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl UnitChunkShared {

/// Returns the raw data for the specified component, assuming a mono-batch.
///
/// Returns an error if the underlying batch is not of unit length.
/// Returns none if the underlying batch is not of unit length.
#[inline]
pub fn component_mono_raw(
&self,
Expand All @@ -369,7 +369,7 @@ impl UnitChunkShared {

/// Returns the deserialized data for the specified component, assuming a mono-batch.
///
/// Returns an error if the data cannot be deserialized, or if the underlying batch is not of unit length.
/// Returns none if the data cannot be deserialized, or if the underlying batch is not of unit length.
#[inline]
pub fn component_mono<C: Component>(&self) -> Option<ChunkResult<C>> {
let res = self.component_mono_raw(&C::name())?;
Expand Down
4 changes: 2 additions & 2 deletions crates/store/re_query/src/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,15 @@ impl LatestAtResults {

/// Returns the deserialized data for the specified component, assuming a mono-batch.
///
/// Returns an error if the data cannot be deserialized, or if the underlying batch is not of unit length.
/// Logs an error if the data cannot be deserialized, or if the underlying batch is not of unit length.
#[inline]
pub fn component_mono<C: Component>(&self) -> Option<C> {
self.component_mono_with_log_level(re_log::Level::Error)
}

/// Returns the deserialized data for the specified component, assuming a mono-batch.
///
/// Returns an error if the data cannot be deserialized, or if the underlying batch is not of unit length.
/// Returns none if the data cannot be deserialized, or if the underlying batch is not of unit length.
#[inline]
pub fn component_mono_quiet<C: Component>(&self) -> Option<C> {
self.components
Expand Down
10 changes: 9 additions & 1 deletion crates/store/re_types/src/archetypes/pinhole_ext.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
use crate::datatypes::Vec2D;
use crate::{components::ViewCoordinates, datatypes::Vec2D};

use super::Pinhole;

impl Pinhole {
/// Camera orientation used when there's no camera orientation explicitly logged.
///
/// - x pointing right
/// - y pointing down
/// - z pointing into the image plane
/// (this is convenient for reading out a depth image which has typically positive z values)
pub const DEFAULT_CAMERA_XYZ: ViewCoordinates = ViewCoordinates::RDF;

/// Creates a pinhole from the camera focal length and resolution, both specified in pixels.
///
/// The focal length is the diagonal of the projection matrix.
Expand Down
26 changes: 24 additions & 2 deletions crates/viewer/re_view/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ pub trait DataResultQuery {
latest_at_query: &'a LatestAtQuery,
) -> HybridLatestAtResults<'a>;

fn latest_at_with_blueprint_resolved_data_for_component<'a, C: re_types_core::Component>(
&'a self,
ctx: &'a ViewContext<'a>,
latest_at_query: &'a LatestAtQuery,
) -> HybridLatestAtResults<'a>;

fn query_archetype_with_history<'a, A: re_types_core::Archetype>(
&'a self,
ctx: &'a ViewContext<'a>,
Expand All @@ -235,14 +241,30 @@ impl DataResultQuery for DataResult {
ctx: &'a ViewContext<'a>,
latest_at_query: &'a LatestAtQuery,
) -> HybridLatestAtResults<'a> {
let query_shadowed_defaults = false;
let query_shadowed_components = false;
latest_at_with_blueprint_resolved_data(
ctx,
None,
latest_at_query,
self,
A::all_components().iter().map(|descr| descr.component_name),
query_shadowed_defaults,
query_shadowed_components,
)
}

fn latest_at_with_blueprint_resolved_data_for_component<'a, C: re_types_core::Component>(
&'a self,
ctx: &'a ViewContext<'a>,
latest_at_query: &'a LatestAtQuery,
) -> HybridLatestAtResults<'a> {
let query_shadowed_components = false;
latest_at_with_blueprint_resolved_data(
ctx,
None,
latest_at_query,
self,
std::iter::once(C::name()),
query_shadowed_components,
)
}

Expand Down
6 changes: 3 additions & 3 deletions crates/viewer/re_view_spatial/src/contexts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod depth_offsets;
mod transform_context;
mod transform_tree_context;

pub use depth_offsets::EntityDepthOffsets;
use re_types::ViewClassIdentifier;
use re_view::AnnotationSceneContext;
pub use transform_context::{TransformContext, TransformInfo, TwoDInThreeDTransformInfo};
pub use transform_tree_context::{TransformInfo, TransformTreeContext, TwoDInThreeDTransformInfo};

// -----------------------------------------------------------------------------

Expand All @@ -24,7 +24,7 @@ pub struct SpatialSceneEntityContext<'a> {
pub fn register_spatial_contexts(
system_registry: &mut re_viewer_context::ViewSystemRegistrator<'_>,
) -> Result<(), ViewClassRegistryError> {
system_registry.register_context_system::<TransformContext>()?;
system_registry.register_context_system::<TransformTreeContext>()?;
system_registry.register_context_system::<EntityDepthOffsets>()?;
system_registry.register_context_system::<AnnotationSceneContext>()?;
Ok(())
Expand Down
Loading
Loading