Skip to content

perf(server): a product's node drawn without the passes of a graph, and its args kept fast - #285

Merged
endrix merged 3 commits into
mainfrom
perf/stock-node-cost
Dec 4, 2026
Merged

endrix merged 3 commits into
mainfrom
perf/stock-node-cost

Conversation

@endrix

@endrix endrix commented Dec 4, 2026

Copy link
Copy Markdown
Owner

A product draws each of its nodes with stockNode, which runs the graph source's pass over a document holding that one node. In mlir-viewer, 8,000 operations mean 8,000 such passes the first time a file is drawn, and every later drawing copies each node's args.

What changes

  • transform(doc, { oneNode: true }). stockNode asks for it, and it skips the passes over a graph's edges and groups: feedback, edges cut at groups, group rows and frames. A document of one node has none of these, so the passes would find nothing to do.
  • markFeedbackEdges. It indexes no port when the graph has no edge, which helps any graph without edges.
  • stockNode args. The document's scope and the stand-in for what an openable node holds are now left out by building a copy, not by delete. V8 makes an object with a deleted key slow to read and to copy, and the product copies these args every time it draws the node.

Measured

mlir-viewer's 8,000-operation timing test, with its part of the change (mlir-viewer PR to follow):

before after
drawn again about 490 ms about 368 ms
drawn the first time about 1,060 ms about 815 ms

The two parts were also timed separately, on one core, with a bundle of the same build. The delete is the largest single item: about 75 ms on a redraw and 125 ms on a first draw. The skipped passes save about 70 ms on a first draw.

Tests

  • New test. A node drawn with oneNode is identical to the full pass's drawing, for a plain node and for one that opens.
  • Suite and checks. diagram-server 1199 tests pass; the typecheck (5/5) and the neutrality check (5/5) pass.

https://claude.ai/code/session_011UYzzShRuBLgefHUrAbqya

…nd its args kept fast

A product draws each of its nodes with `stockNode`, through the graph
source's pass over a document of that one node: 8,000 operations in
mlir-viewer are 8,000 passes the first time a file is drawn, and every
later drawing copies each node's args. Measured on mlir-viewer's
8,000-operation test, with its part of the change: the first drawing
from about 1,060 ms to about 815 ms, a drawing again from about 490 ms
to about 368 ms.

- `transform(doc, { oneNode: true })`, which `stockNode` asks for, does
  not run the passes over a graph's edges and groups (feedback, edges
  cut at groups, rows, frames): a document of one node has none. A test
  holds that the node is drawn the same either way, one that opens too.
- `markFeedbackEdges` indexes no port when a graph has no edge.
- `stockNode` leaves out the document's scope and the stand-in for what
  the node holds by a copy, not a `delete`: an object a key is deleted
  from is slow to read and to copy, and the product copies these args
  each time it draws the node.

Claude-Session: https://claude.ai/code/session_011UYzzShRuBLgefHUrAbqya
…o edge

From the review of #285: `oneNode` was the caller's word alone. It is
not taken when the document has an edge or another node, or the
reader's choices may open the node, and a test holds that a document of
two nodes on a loop has its edges marked as ever. The comment in
`markFeedbackEdges` no longer names a pass that does not reach it.

Claude-Session: https://claude.ai/code/session_011UYzzShRuBLgefHUrAbqya
@endrix
endrix merged commit 7e7c951 into main Dec 4, 2026
1 check 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