Do not pre-render each visual's children twice per frame (backport #1309)#1312
Open
mergify[bot] wants to merge 1 commit into
Open
Do not pre-render each visual's children twice per frame (backport #1309)#1312mergify[bot] wants to merge 1 commit into
mergify[bot] wants to merge 1 commit into
Conversation
15 tasks
Assisted-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Carlos Aguero <caguero@honurobotics.com> (cherry picked from commit d1b6cba)
caguero
force-pushed
the
mergify/bp/gz-rendering9/pr-1309
branch
from
July 9, 2026 08:58
3c22ab0 to
7b284b5
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## gz-rendering9 #1312 +/- ##
=================================================
+ Coverage 76.03% 76.46% +0.42%
=================================================
Files 180 180
Lines 17240 17274 +34
=================================================
+ Hits 13109 13208 +99
+ Misses 4131 4066 -65 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🦟 Bug fix
Summary
BaseVisual::PreRender()pre-renders each visual's children twice every frame. It callsT::PreRender(), which resolves toBaseNode::PreRender()and already recurses into the children through the virtualPreRenderChildren(), and then callsPreRenderChildren()again explicitly. Because the duplication happens at every level of the scene graph, it compounds to O(2^depth) redundant traversals: the more deeply nested a scene's model → link → visual hierarchy, the worse it gets.This patch removes the redundant call so each visual's children are pre-rendered exactly once.
Benchmark results
Measured on the Gazebo GUI process (
gz-sim-gui-client, OgreNext + NVIDIA), matchedRelWithDebInfobuilds, before → after:BaseVisual::PreRenderChildren(inclusive)The saving shows up as a higher frame rate when the render thread is the bottleneck (the 3000-shape scene was render-bound at 33 FPS) and as lower CPU when the scene already reaches the vsync target (jetty). The relative reduction in
PreRenderChildrengrows with scene-graph depth, so deeply nested worlds (jetty) see the largest cut.Backport Policy
Checklist
codecheckpassedNote to maintainers: Remember to use Squash-Merge and edit the commit
message to match the pull request summary while retaining the
Signed-off-bylines.
This is an automatic backport of pull request #1309 done by [Mergify](https://mergify.com).