Skip to content

Do not pre-render each visual's children twice per frame (backport #1309)#1313

Open
mergify[bot] wants to merge 1 commit into
gz-rendering8from
mergify/bp/gz-rendering8/pr-1309
Open

Do not pre-render each visual's children twice per frame (backport #1309)#1313
mergify[bot] wants to merge 1 commit into
gz-rendering8from
mergify/bp/gz-rendering8/pr-1309

Conversation

@mergify

@mergify mergify Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🦟 Bug fix

Summary

BaseVisual::PreRender() pre-renders each visual's children twice every frame. It calls T::PreRender(), which resolves to BaseNode::PreRender() and already recurses into the children through the virtual PreRenderChildren(), and then calls PreRenderChildren() 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), matched RelWithDebInfo builds, before → after:

World FPS Total GUI CPU BaseVisual::PreRenderChildren (inclusive)
3000 static shapes 33 → 58 (+73%) ~flat 52% → 32%
3000 moving shapes 52 → 64 (+24%) −30% less CPU 53% → 35%
jetty (~320 models) ~60 (vsync-capped) −15% less CPU 22% → 10%

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 PreRenderChildren grows with scene-graph depth, so deeply nested worlds (jetty) see the largest cut.

Backport Policy

  • This is safe to backport to the following versions:
    • Jetty
    • Ionic
    • Harmonic
    • Fortress
  • This should not be backported
  • I am not sure
  • Other (fill in yourself)

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed
  • All tests passed

Note to maintainers: Remember to use Squash-Merge and edit the commit
message to match the pull request summary while retaining the Signed-off-by
lines.


This is an automatic backport of pull request #1309 done by [Mergify](https://mergify.com).

@mergify
mergify Bot requested a review from iche033 as a code owner July 9, 2026 08:50
@github-actions github-actions Bot added the 🎵 harmonic Gazebo Harmonic label Jul 9, 2026
Assisted-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
(cherry picked from commit d1b6cba)
@caguero
caguero force-pushed the mergify/bp/gz-rendering8/pr-1309 branch from 1df2f6d to 30f0085 Compare July 9, 2026 08:58
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.13%. Comparing base (6f1ee65) to head (30f0085).
⚠️ Report is 16 commits behind head on gz-rendering8.

Additional details and impacted files
@@                Coverage Diff                @@
##           gz-rendering8    #1313      +/-   ##
=================================================
+ Coverage          75.60%   76.13%   +0.53%     
=================================================
  Files                177      177              
  Lines              17012    16993      -19     
=================================================
+ Hits               12862    12938      +76     
+ Misses              4150     4055      -95     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎵 harmonic Gazebo Harmonic

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

2 participants