Perf: Optimize scene snapshot materialization - #59
Merged
Merged
Conversation
Changed - Scene snapshot materialization now routes through a dedicated materializer in the rendering state layer instead of concentrating ordering, indexing, and edge cleanup inside the snapshot constructor - Scene snapshot construction now reuses lightweight ordered node and remapped edge views while replacing duplicated node snapshot indexing with compact id to position map - Rendering benchmarks and fixtures now exercise the materializer path directly, and scene snapshot regression tests cover node ordering, lookup, and edge remapping behavior Result Scene snapshot materialization keeps the same observable scene semantics while reducing constructor work, improving the 100000 event benchmark from 110.26 ms to 51.55 ms and lowering managed allocation from 26.77 MB to 3.85 MB.
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.
Summary
Optimize scene snapshot materialization by moving ordering, indexing, and edge cleanup into dedicated materializer while preserving current render state semantics.
Added
Changed
SceneSnapshotnow uses a compact id-to-position lookup instead of duplicating full node snapshots in a second indexSceneSnapshotMaterializerinstead of concentrating sorting, indexing, and edge cleanup inside the snapshot constructorDistinctBypasses in the constructorFixed
Result
Scene snapshot materialization now does less repeated indexing and constructor work while preserving the same observable render state behavior.
At
100000events:MaterializeSceneSnapshot:110.26 ms->51.55 ms,26.77 MB->3.85 MBTesting
dotnet test Tests/ChangeTrace.Tests.csproj --filter "FullyQualifiedName~ChangeTrace.Tests.Rendering.States"dotnet run -c Release --project Benchmarks/ChangeTrace.Benchmarks.csproj -- --filter "*SceneSnapshotComponentBenchmarks.MaterializeSceneSnapshot*"Additional notes:
States/Scenewhile snapshot model types remain in the existing snapshot area.Linked Issues
Checklist