Repository navigation
perf(lod): cache display bounds per graph revision and skip idle LOD passes - #45
Merged
Merged
Conversation
… are skipped The LOD pass reads every displayed body's bounds from the kernel on every pass, and the kernel re-validates each stored B-rep on every read. These tests pin the intended behaviour: one bounds read per body per graph revision, no pass while nothing it reads has changed, the same buckets as an uncached run, and kernel bounds that stay the enclosure recorded from the validating code on the storey and pan-and-inset scenes.
Every LOD pass read each displayed body's bounds from the kernel, and the kernel re-validated the whole stored B-rep on each read, so a 2,500 body scene spent about 90 ms per pass even with a still camera. Every shape enters the store through the commit path, which validates it, so the bounds queries now enclose the stored B-rep without validating it again. The SDK keeps each body's bounds until the graph revision moves, and a non-forced pass is skipped while nothing it reads has changed: the graph and flushed revisions, the camera, the moving state, the displayed set and the LOD state edits. Forced passes and the 100 ms interval are unchanged, so the chosen buckets match the uncached run.
Every other kernel call goes through call(), which poisons the runtime when the kernel traps. The revision read added for the pass staleness check called the getter directly, so a trap there would escape the guard. It now uses the same wrapper as the flush revision read.
This was referenced Nov 3, 2026
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.
What
The LOD pass read each displayed body's bounds from the kernel every 100 ms, and each read re-validated the whole stored B-rep. With a few thousand bodies the pass took about 100 ms, so it ran back to back and the main thread never rested, with the camera still or moving.
rendering/lod/display-bounds.ts).One LOD pass on the current kernel: 2,313 bounds reads, 99 ms. Same picture and draw calls on both.
Verification (after rebase onto
5998d0b)cargo test --test world_graph: 61 passed, 1 ignored (newdisplay_bounds.rs).npm run typecheck,npm run lint:check,npm run build: pass.opengeometry-three/tests/node/display-bounds.test.mjs: 5 of 5 (bounds read once per graph revision; idle passes skipped).npm run test:node: 209 of 209.