Repository navigation
Conversation
Adds an internal research prototype of a declarative scene (nothing is exported from the package): - packages/graph/src/lib/scene: primitive and element types, drawElements (Canvas2D drawing with run-batching of same-style paths, capped by maxRun), SceneStore (elements on a TileIndex in zIndex/sequence order), ScenePathBatch (paths and polygons of one z-level cached per cell on the core BatchScene, as BatchPath2DRenderer caches connections) and SceneCanvasLayer (draws a store and its batches in z-order). Adds a scene bench next to the culling bench: - scripts/bench/culling/scene-run.mjs and scene/: deterministic median, guarantee and stress scenes with a Nirvana-like look, drawn by three columns: walk (today's component tree), interpreter (SceneCanvasLayer over a SceneStore) and cached (connections in a ScenePathBatch). It times pan, zoom and drag on the scheduler tick plus the synchronous action, diffs the pictures against walk, and can record CPU profiles. Flags: --renderers, --run-cap, --gpu, --query-timing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideData structuresDefine the scene primitives, visibility rules, element fields, and coordinate conventions that the store and renderer rely on.
Store scene elements in a tile index and return visible elements in z-index and sequence order.
Represent cached path and polygon elements as chunked, per-cell batch data with add, update, delete, and render operations.
Define the deterministic benchmark scenes, their block and connection data, and the shared visual primitives used to construct them.
ImplementationDraw scene primitives with Canvas2D, preserving ordering around shapes while batching compatible paths and polygons into capped runs.
Implement the canvas layer that queries visible store elements and interleaves them with batches by z-index.
Build and run the browser benchmark, including renderer selection, timing, screenshots, pixel comparisons, and profiling options.
Provide the benchmark’s browser harness and walk/interpreter adapters, including measured actions, scene setup, and query timing.
DocumentationExplain the scene benchmark’s renderers, measurement methodology, limitations, and command-line options.
TestsCheck scene-layer visibility, batching, z-order, run limits, and camera-to-world viewport conversion.
Check cached path-batch construction, viewport culling, updates, validation, chunking, and rendering behavior.
Check scene-store ordering, visibility, movement, deletion, and duplicate-id handling.
Check primitive visibility, text sizing, shape borders, path-run batching, and draw ordering.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Preview is ready. |
Summary
A research prototype for a unified scene renderer. It is a declarative scene of primitives drawn by a Canvas2D interpreter, plus a bench that compares it with today's component walk on Nirvana-sized graphs. It answers whether the data model alone, without WebGL, gives most of the frame-time win.
Nothing is exported from the package, and library behaviour is unchanged. The PR is stacked on #451.
Prototype (
packages/graph/src/lib/scene, internal)types.ts: primitives (rect, circle, text, icon, path, polygon) with scale visibility, and scene elements.drawPrimitives.ts:drawElements()draws elements with Canvas2D.filland onestroke.maxRun, because Chromium'sPath2D.closePath()costs time in proportion to the path built so far.SceneStore.ts: elements on aTileIndex, returned in(zIndex, sequence)order.ScenePathBatch.ts: the paths and polygons of one z-level, cached per grid cell on the coreBatchScene(cell 8192, chunk 200, chunk paths built withaddPath), asBatchPath2DRenderercaches connections.SceneCanvasLayer.ts: a layer that draws a store and its batches in z-order.Bench (
scripts/bench/culling/scene-run.mjs,scripts/bench/culling/scene/)walk: core components with Nirvana-like canvas blocks;interpreter: aSceneCanvasLayerover aSceneStore;cached: the same with connections in aScenePathBatch.walk;--renderers;--run-cap;--gpu: ANGLE Metal, asrun.mjsuses. Without it, Playwright's Chromium rasterizes in software (SwiftShader).--query-timing.Results
GPU, Apple M3 Pro, guarantee scene, 1600×1000 view, pan. Main-thread tick in ms, mean of 40 actions, 3 repeats:
cachedremoves 71–78% of the gap betweenwalkand a 4 ms target. For any target from 0 ms up, the share stays at 63.5% or more.cachedis not slower thanwalkin any of the 32 measured cells: guarantee, median and stress; pan, zoom and drag.cachedtick, about 84% is the per-element drawing of blocks and anchors (an estimate from one profile).Test plan
pnpm --dir packages/graph exec jest: 1012 passed, 6 todopnpm --dir packages/graph exec tsc --noEmit -p tsconfig.jsonpnpm --dir packages/graph exec eslint src/lib/sceneGRAPH/GRAPH_SRCaliases. The package tsconfig does not cover them.node scripts/bench/culling/scene-run.mjs --gpu --scenes guarantee --scales 0.038,0.05 --renderers walk,interpreter,cached --run-cap 25 --repeats 3🤖 Generated with Claude Code
Summary by Sourcery
Prototype an internal scene interpreter and benchmark its Canvas2D and cached-path rendering performance against the existing component walk.
New Features:
Enhancements:
Documentation:
Tests: