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

Introduce versioned EntityPath & refactor mesh/tensor caching #3230

Merged
merged 17 commits into from
Sep 6, 2023

Conversation

teh-cmc
Copy link
Member

@teh-cmc teh-cmc commented Sep 6, 2023

Commit by commit

What the title says.

The most important contribution of this PR is the new VersionedInstancePath[Hash] types, which further specializes an InstancePath[Hash] (itself a specialization of EntityPath) with extra versioning information in the form of a RowId from the store.
I.e. a VersionedInstancePath gives you a specific instance of an entity at a specific path at a specific time and row in the store, which is as specific as it gets.

This allows us to completely remove MeshId & TensorId, and paves the way for generic frame-based caching.

What

Checklist

@teh-cmc teh-cmc changed the title Introduced versioned EntityPath & refactor mesh/tensor caching (sunset MeshId/TensorId) Introduced versioned EntityPath & refactor mesh/tensor caching Sep 6, 2023
@teh-cmc teh-cmc changed the title Introduced versioned EntityPath & refactor mesh/tensor caching Introduce versioned EntityPath & refactor mesh/tensor caching Sep 6, 2023
@teh-cmc teh-cmc added 🐍 Python API Python logging API 🦀 Rust API Rust logging API 📺 re_viewer affects re_viewer itself 🌊 C++ API C/C++ API specific labels Sep 6, 2023
@teh-cmc teh-cmc marked this pull request as ready for review September 6, 2023 12:41
Copy link
Member

@jleibs jleibs left a comment

Choose a reason for hiding this comment

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

I love how much this cleans up!

Couple suggestions on how to streamline some plumbing, specifically by shoving some more data into DecodedTensor but otherwise looks great.

///
/// This assumes that the row we get from the store only contains a single instance for this
/// component; it will log a warning otherwise.
///
/// This should only be used for "mono-components" such as `Transform` and `Tensor`.
///
/// This is a best-effort helper, it will merely log errors on failure.
pub fn query_latest_component<C: Component>(
pub fn query_latest_component_and_row_id<C: Component>(
Copy link
Member

Choose a reason for hiding this comment

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

Rather than "component_and_row_id" what if this the result-type was just a "VersionedComponent"?

pub fn query_latest_component<C: Component>(
        &self,
        entity_path: &EntityPath,
        query: &LatestAtQuery,
    ) -> Option<VersionedComponent<C>>

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting. I'll try and see how this looks.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've implemented it and I think it's a nice enough improvement as it at least prevents the combinatorial explosion of query_latest_* APIs.

Overall the whole thing is definitely not great, there is so much more we could do if the notion of versioning was more tightly integrated (or rather: integrated at all) all over the codebase overall but... gotta 🚢 !

@@ -348,7 +348,7 @@ impl<A: Archetype> ArchetypeView<A> {
components: impl IntoIterator<Item = ComponentWithInstances>,
) -> Self {
Self {
row_id,
primary_row_id: row_id,
Copy link
Member

Choose a reason for hiding this comment

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

The correct caching behavior of Tensor depends on this id being the id of the TensorData component. This will currently be the case for our definitions of Image / Tensor but may not always be the case if we introduce an archetype with an optional tensor.

I suspect this means we should do the book-keeping through so that every ComponentWithInstances knows its own RowId.

Since it's not a blocker today we can probably get away with just an issue / comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! I actually meant to add a comment about that and forgot. Will do.

@@ -61,19 +61,22 @@ pub struct PerTensorState {

/// Last viewed tensor, copied each frame.
/// Used for the selection view.
tensor: Option<DecodedTensor>,
tensor: Option<(VersionedInstancePathHash, DecodedTensor)>,
Copy link
Member

Choose a reason for hiding this comment

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

I think we can simplify this by having DecodedTensor track the RowId itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

The issue is that DecodedTensor is completely unaware of Rerun and can be constructed from e.g. a DynamicImage and nothing else.

Which I think is a good thing really, even if that wasn't the case I wouldn't feel too great about coupling this to specific query patterns.

examples/rust/raw_mesh/Cargo.toml Outdated Show resolved Hide resolved
@teh-cmc teh-cmc merged commit 9ad0da2 into main Sep 6, 2023
@teh-cmc teh-cmc deleted the cmc/get_rid_of_tensor_id branch September 6, 2023 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌊 C++ API C/C++ API specific 🐍 Python API Python logging API 📺 re_viewer affects re_viewer itself 🦀 Rust API Rust logging API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants