Skip to content

Perf: Prevent pipeline from aging scene after timeline finishes - #61

Merged
rian-be merged 1 commit into
mainfrom
render_snapshot_optimizations
Jun 16, 2026
Merged

rian-be merged 1 commit into
mainfrom
render_snapshot_optimizations

Conversation

@rian-be

@rian-be rian-be commented Jun 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stop continuous scene aging and cache invalidation when the playback reaches the Finished state. This prevents full snapshot rebuilds on every frame when the visual state is static, delivering massive performance and allocation improvements.

Added

  • State caching mechanism to RenderStateAssembler and ExtensionStatisticsAssembler to bypass snapshot rebuilds when visual state remains unchanged
  • Snapshot caching to RenderEventBuffer to reuse identical scene states efficiently

Changed

  • SceneFrameUpdater now correctly freezes delta time (dt) for the Finished playback state, matching existing behavior for Idle and Paused
  • Re-enabled rendering cache logic inside the pipeline to utilize identical snapshots instead of defaulting to full rebuilds

Fixed

  • Prevented the pipeline from updating the scene based on wall time after the timeline had already completed, which kept invalidating the cache unnecessarily
  • Eliminated massive per-frame allocation overhead during static scene playback states

Result

Cache hits now properly resolve during idle and finished playback states. Rendering interaction benchmarks demonstrate a massive speedup and drastically reduced per-frame allocations.

At 100000 events:

  • SweepHoverAndRenderFrames: 726.256 ms -> 64.122 ms
  • PanZoomAndRenderFrames: 758.712 ms -> 44.596 ms
  • ToggleLayoutAndRenderFrames: 763.527 ms -> 59.904 ms
  • Allocations (Sweep): 179.5 MB -> 14.34 KB
  • Allocations (PanZoom): 179.5 MB -> 13.88 KB
  • Allocations (Toggle): 179.5 MB -> 13.88 KB

At 10000 events:

  • Sweep: 40.643 ms -> 1.753 ms
  • PanZoom: 42.000 ms -> 1.414 ms
  • Toggle: 41.236 ms -> 1.619 ms

Testing

[✓] dotnet test Tests/ChangeTrace.Tests.csproj --filter "FullyQualifiedName~ChangeTrace.Tests.Rendering.States"
[✓] dotnet run -c Release --project Benchmarks/ChangeTrace.Benchmarks.csproj -- --filter "*RenderingInteractionWorkflowBenchmarks*"

Linked Issues

Checklist

[✓] PR is focused and does not include unrelated cleanup
[✓] Public API changes are documented
[✓] Breaking changes are explicitly described
[✓] New behavior follows existing project architecture
[✓] I followed the Code of Conduct /CODE_OF_CONDUCT.md

Added

- State caching mechanism to RenderStateAssembler and ExtensionStatisticsAssembler
- Snapshot caching to RenderEventBuffer for unchanged scene states

Changed

- SceneFrameUpdater now properly freezes delta time for `Finished` state, matching `Idle` and `Paused`
- Re-enabled rendering cache logic to utilize identical snapshots instead of full rebuilds

Result

Cache hits now properly resolve during idle and finished playback states.
Rendering interaction benchmarks (100000 events) demonstrate significant improvements:
- SweepHoverAndRenderFrames: 726.256 ms -> 64.122 ms
- PanZoomAndRenderFrames: 758.712 ms -> 44.596 ms
- ToggleLayoutAndRenderFrames: 763.527 ms -> 59.904 ms

Allocations per frame dropped drastically from ~179.5 MB to ~14 KB.
@rian-be rian-be added Renderer Renderer pipeline and visual output changes Performance Performance improvements or regressions tests Test coverage and test changes Benchmark Benchmark coverage and performance measurement changes labels Jun 16, 2026
@rian-be rian-be self-assigned this Jun 16, 2026
@github-actions github-actions Bot removed tests Test coverage and test changes Benchmark Benchmark coverage and performance measurement changes labels Jun 16, 2026
@rian-be
rian-be merged commit 4248580 into main Jun 16, 2026
26 checks passed
@rian-be
rian-be deleted the render_snapshot_optimizations branch June 16, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Performance Performance improvements or regressions Renderer Renderer pipeline and visual output changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Benchmark and optimize rendering interaction workflow performance

1 participant