EntityTree: only check for entity deletions when necessary#8103
EntityTree: only check for entity deletions when necessary#8103
EntityTree: only check for entity deletions when necessary#8103Conversation
| self.children.retain(|_, entity| { | ||
| // this is placed first, because we'll only know if the child entity is empty after telling it to clear itself. | ||
| entity.on_store_deletions(engine, events); | ||
| entity.on_store_deletions(engine, entity_paths_with_deletions, events); |
There was a problem hiding this comment.
I'm not totally following how this improves performance.
The inclusion of entity_paths_with_deletions doesn't change the fact that on_store_deletions does an entire tree-walk.
Is the whole point of this optimization to bypass the overhead of the is_empty() call in cases where we know that the intermediate child couldn't have been deleted?
That said, this seems like this will no longer successfully delete intermediate children that only existed as containers for other entities but don't have their own data.
There was a problem hiding this comment.
The inclusion of
entity_paths_with_deletionsdoesn't change the fact thaton_store_deletionsdoes an entire tree-walk.Is the whole point of this optimization to bypass the overhead of the
is_empty()call in cases where we know that the intermediate child couldn't have been deleted?
Yeah, the tree walk in itself is imperceptible (it's just a few thousands recursions in the worst case, it's barely measurable) -- a few thousands is_empty() on the other hand is extremely costly.
This PR basically brings the latency down from several seconds (ever increasing) to a constant 10ms (using the benchmark script in the issue).
That said, this seems like this will no longer successfully delete intermediate children that only existed as containers for other entities but don't have their own data.
Haa! I didn't even know that that was the point of this thing. We need to tweak this slightly then.
There was a problem hiding this comment.
a few thousands is_empty() on the other hand is extremely costly
Got it -- that wasn't obvious at all and definitely warrants a comment then. I wonder if is_empty() should be renamed to something like check_if_empty() to better imply there's an active cost to be paid and it's not just accessing some pre-computed state.
Before:

After:

Checklist
mainbuild: rerun.io/viewernightlybuild: rerun.io/viewerCHANGELOG.mdand the migration guideTo run all checks from
main, comment on the PR with@rerun-bot full-check.