-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Child spawning optimizations #17339
base: main
Are you sure you want to change the base?
Child spawning optimizations #17339
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rationale for your changes looks sound to me. Just a minor nit around alloc::vec::Vec
.
let events = children | ||
.iter() | ||
.map(|&child| HierarchyEvent::ChildAdded { child, parent }) | ||
.collect::<alloc::vec::Vec<_>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer use alloc::vec::Vec;
at the top of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes make sense and look solid to me.
I have a few more changes locally I need to push. I noticed that some of the child methods send a hierarchy event, but some do not. I can't tell if this is an error or not. The docs don't really spell out any intent. |
Can anyone with more familiarity please comment on the |
Objective
Solution
Testing
spawn_children
benchmarkShowcase
Fixed exponential time complexity when spawning children on an entity that already has existing children. This case can now complete in linear time.
Note the 1 million case takes 111ms on this branch. On
main
, I had to kill the test because it was estimated to take 8 hours.