Skip to content

Improve frame pacing and expose rendering and simulation timings - #5

Merged
fred-huang122 merged 4 commits into
masterfrom
perf/render-cadence
Nov 2, 2026
Merged

fred-huang122 merged 4 commits into
masterfrom
perf/render-cadence

Conversation

@fred-huang122

@fred-huang122 fred-huang122 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

The 60 FPS setting used a repeating 17 ms timer and stopped requesting frames whenever physics fell two ticks behind. Schedule rendering against absolute deadlines, skip missed render deadlines, and continue drawing completed immutable snapshots while the existing lag warning reports simulation delay.

  • Count normal window frames after Qt's paint/swap call; screenshots no longer inflate displayed FPS. The tooltip explicitly distinguishes frame submission from compositor presentation.
  • Keep bounded recent p50/p95/p99 measurements for scene/labels, frame intervals, paint plus swap, simulation ticks and snapshot construction. Recording does not allocate or sort in the drawing hot path.
  • GRSIM_PROFILE_RENDERING=1 enables four reusable asynchronous GPU-query slots. Query IDs remain in their owning window context; temporary screenshot contexts are excluded and cleanup switches to the owner before deleting IDs. Results are read only when available. The default creates no GPU queries.

Validation: all 25 local regressions pass in 70.18 s. Deterministic deadline tests cover 1/5/59.94/60/120/1000 FPS, invalid inputs, late deadlines and bounded histories. Real-window regressions fail on the old rounded/backlog policy and pass after the fix. A screenshot regression reproduces GL_INVALID_OPERATION on every context switch before the query-lifetime fix, then verifies clean resumed window frames afterward. Existing picking, framebuffer, fallback, HiDPI, worker, physics and collision checks remain enabled. Direct double-precision ODE, collision geometry/materials, tolerances, timestep and five substeps are unchanged.

The cadence change removes a software scheduling limit; it does not establish sustained 60 FPS for the full-detail scene. Three paired 6 v 6 rounds at a 956x545 viewport, 3 s warmup + 3 s measurement, stock Mesa 25.2.8 and the actual RTX 4060 Laptop D3D12 context give:

Case Previous FPS Cadence change FPS New simulation/wall speed
Spaced 55.4 54.3 0.999x
Crowd 53.4 53.3 1.000x
Pushing 53.0 53.0 0.998x

These paired trials measure commit 8503a78 before the later optional-query lifetime cleanup. Previous FPS counts end-of-draw callbacks; new FPS counts paint/swap completion. No average-throughput speedup is claimed. Existing workloads remain running; GPU use with grSim closed ranges 0–23% during this matrix.

The final f0a659e app also tests the larger 1596x825 viewport. At normal detail it remains below 60 FPS. Three final Low Spec trials per case give spaced 59.35–60.20 FPS (median 59.94) and pushing 55.72–60.05 FPS (median 56.95), with simulation/wall ratios 0.995–1.001 and maximum observed backlog below 21 ms. Low Spec changes rendering detail/resolution; physics accuracy is unchanged. It can reach 60 FPS but does not sustain that in every pushing run.

Profiling separates under-1-ms scene submission and roughly 0.3-ms labels from much longer completion/swap waits. Clear, robot-only and field-only probes reach about 60 FPS, while the combined full-detail scene remains slower. Swap overrides, batching and private-Mesa experiments do not provide a validated production fix; prototypes and all raw profiling data stay outside Git.

Latest CI passes Ubuntu 22.04/24.04 and native arm64 macOS 26, including its OpenGL runtime checks. The final macOS 15 build/package job remains queued, so the dependent exact-package launch on macOS 26 is pending. The earlier cadence head packaged and launched successfully on macOS 15. Hosted Mac graphics use Apple Software Renderer and do not establish physical Mac GPU throughput.

Stacked on #4. Physics replay and measurement tooling is independent in #6, based on #3.

@fred-huang122
fred-huang122 changed the base branch from perf/render-device-status to master November 2, 2026 17:33
@fred-huang122
fred-huang122 merged commit 0f86396 into master Nov 2, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant