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

Filter entities in the UI (part 6): Refactor re_blueprint_tree and add more tests #8795

Merged
merged 18 commits into from
Jan 28, 2025

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Jan 23, 2025

Related

What

This PR introduces a complete refactor of the blueprint tree to split the data processing part (including filtering) and the UI part. It also introduce a bunch of UI snapshot and insta tests to protect us against regressions.

Visual changes

This refactor highlighted a number of bugs and inconsistencies in the way we're presenting the blueprint tree.

  • In20d271c, the UI snapshot test are introduced, along with the snapshots corresponding to the previous state.
  • In 6273573, the snapshot are updated for the new implementation, so it's a good place to review the presentation changes.

Example of a bug (wrong highlighting of the '(root)' label:
image

Example of an inconsistency (we display an origin stub but wouldn't match on it):

image

Performance

Technically, this PR introduce a performance regression in the sense that we now always walk the entire tree to extract data, even if such data is not needed—e.g. because the display is fully collapsed and not filtered.

However, benchmark have shown that this overhead is very small, and far outweighed by the gain in code clarity.

Full benchmark analysis/discussion on slack: https://rerunio.slack.com/archives/C041NHU952S/p1737709242394899

TL;DR: 0.3ms in a complex case where the entire blueprint tree takes 3.6ms.

image

Comparing with 0.21 shows not significant regression.

This PR:

image

0.21.0:

image

setup used:

image

fixed bug in data

fixed data
test passing for old code

improved test code

fixed test
@abey79 abey79 added ui concerns graphical user interface 🚜 refactor Change the code, not the functionality include in changelog labels Jan 23, 2025
@abey79 abey79 marked this pull request as draft January 23, 2025 19:24
Copy link

github-actions bot commented Jan 23, 2025

Web viewer built successfully. If applicable, you should also test it:

  • I have tested the web viewer
Result Commit Link Manifest
8ec00fb https://rerun.io/viewer/pr/8795 +nightly +main

Note: This comment is updated whenever you push a commit.

@abey79 abey79 force-pushed the antoine/filt6-blueprint-view-refactor branch from 974a30a to e0dbdf4 Compare January 23, 2025 21:12
@abey79 abey79 marked this pull request as ready for review January 24, 2025 10:35
Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Great!

crates/viewer/re_blueprint_tree/src/blueprint_tree.rs Outdated Show resolved Hide resolved
crates/viewer/re_blueprint_tree/src/data.rs Outdated Show resolved Hide resolved
crates/viewer/re_blueprint_tree/src/data.rs Outdated Show resolved Hide resolved
crates/viewer/re_blueprint_tree/src/data.rs Outdated Show resolved Hide resolved
Comment on lines +200 to +207
result_tree.visit(&mut |node| {
if node
.data_result
.entity_path
.starts_with(&view_blueprint.space_origin)
{
// If it's under the origin, we're not interested, stop recursing.
false
Copy link
Member

Choose a reason for hiding this comment

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

Reading this code it's not immediately obvious what returning false from visit means. It's not a huge issue, but it could probably be made easier to read by using something like std::ops::ControlFlow

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call! This existing visit method is used in a bunch of places so I won't change it here, but I'll keep that in mind and might do a separate cleanup PR.

crates/viewer/re_blueprint_tree/src/data.rs Outdated Show resolved Hide resolved
crates/viewer/re_blueprint_tree/src/data.rs Outdated Show resolved Hide resolved
@abey79 abey79 merged commit bf4c684 into main Jan 28, 2025
31 checks passed
@abey79 abey79 deleted the antoine/filt6-blueprint-view-refactor branch January 28, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 🚜 refactor Change the code, not the functionality ui concerns graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants