-
Notifications
You must be signed in to change notification settings - Fork 289
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
Use ComponentState::PeriodicChange in UpdateState to avoid forcing full scene update #486
Conversation
Four times faster than a standalone sim, or the previous implementation? |
Than the previous implementation. I don't think that the simple |
Some actual numbers in my machine using the
Using the
Note: The RTF numbers above is an "average" I made from visually inspecting the RTF factor in the GUI, so don't get them too seriously ... it's just an rough approximation to understand the performance benefit. |
Could this be changed to target |
I took a quick look and targeting (edit) tomorrow, not on Monday 😂 |
68cdcb7
to
c8a432f
Compare
Codecov Report
@@ Coverage Diff @@
## main #486 +/- ##
==========================================
+ Coverage 77.56% 77.62% +0.05%
==========================================
Files 211 211
Lines 11579 11582 +3
==========================================
+ Hits 8981 8990 +9
+ Misses 2598 2592 -6
Continue to review full report at Codecov.
|
@mjcarroll @chapulina friendly ping. |
Nice catch. My concern is that important one-time changes may be missed if we make all changes period. For example, the color of a light is changed in one secondary, and another secondary misses it and keeps seeing the old color.
Yeah I think this could work. We'd have to target this PR at Edifice though ( |
… a full scene Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
57f121f
to
93d1ea7
Compare
Done. Each time I change the base branch I bring more reviewers 😂 |
Is there a PR to
This is related to something @luca-della-vedova was looking into recently. They have a use case using animated actors which could take advantage of more granular |
Now there is 😄 gazebosim/gz-msgs#119 .
But in that case, the changes that aren't needed can be omitted from the state message, right? |
Yeah good point, they shouldn't be there at all when they aren't needed. I'm just trying to think now of any downsides to marking periodic changes as one time changes. The receiving end of that state message won't be able to tell apart which are the one time changes. Are you concerned about the overhead of marking every single component? In any case, I think it's worth it trying the current approach. We can always add more granularity later if needed. |
Now that this requires |
Yes that's true, if there's a potential benefit of having that information in the message maybe it's better to add it now.
It will add some overhead, but probably minimal. It requires N lookups to this std::map while iterating the components to add to the message. |
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
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.
there's no code currently telling apart periodic changes from one time changes
So far 😉 But we may be changing this soon for performance. In any case, I think this may not affect the internals of the State
/ SetState
calls.
This looks ok for me, but we need to wait for the transition to ign-msgs7
to be complete before merging (gazebo-tooling/release-tools#362).
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
I have pushed a branch with #481 rebased for The instructions to build, run the simulation and see the results are here, feel free to ask if that's not clear. PS: #481 already includes an optimization similar to this PR, so this one doesn't need to be rebased to |
Tested, the |
re: citadel: This needs to target Edifice because of the new message field. |
Let's get this in! We still have a couple months until the Edifice release to revert in case we notice something weird. |
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
When trying to implement primary-secondary async stepping in #481, I found out that there was almost no speed-up in doing that because the primary was running quite slowly.
After some profiling I realized that the SceneBroadcaster::PostUpdate step was much slower than in an standalone simulation because a full scene update was always forced.
This PR modifies
EntityComponentManager::SetState(const ignition::msgs::SerializedStateMap &_stateMsg)
so when a component is updated aComponentState::PeriodicChange
change is set instead of aComponentState::OneTimeChange
, avoiding to regenerate a full scene all the time.With this change, the
distributed_levels
example works ~4 times faster when using a distributed simulation.I'm not sure if using
ComponentState::PeriodicChange
is always correct, so we can consider the following alternatives:NetworkManagerPrimary::Step
is not the only consumer ofEntityComponentManager::SetState
.If for the other consumers doing a
ComponentState::OneTimeChange
is not a problem and forNetworkManagerPrimary::Step
usingComponentState::PeriodicChange
is always ok, I could add an extra argument to the method.ComponentState::OneTimeChange
make more sense and for othersComponentState::PeriodicChange
make more sense, the we should add that information to theSerializedStateMap
message.