Skip to content

Compute the Graph View's visible entities once per change - #2128

Merged
kmcginnes merged 3 commits into
mainfrom
graph-style-render-performance
Dec 1, 2026
Merged

kmcginnes merged 3 commits into
mainfrom
graph-style-render-performance

Conversation

@kmcginnes

@kmcginnes kmcginnes commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Every expand recomputed the visible vertices twice and added a cache entry that nothing could reach again.

User-facing: nothing looks different. Each expand does one pass instead of two and leaves no cache entry behind.

 GraphViewer
-  useRenderedVertices()            # pass 1
-  useRenderedEdges()
-    useRenderedVertices()          # pass 2, same work again
+  useRenderedEntities()
+    visibleCanvasVerticesAtom      # one shared pass, filtered from nodesAtom
+    visibleDisplayVerticesAtom

-displayVerticesSelector = atomFamily((vertices: Vertex[]) => …)        # new key per node-set change, never evicted
-allFetchedNeighborsSelector = atomFamily((ids: VertexId[]) => …)       # same
+displayVerticesInCanvasSelector = atom(get => map canvas vertices through displayVertexSelector)
+allFetchedNeighborsAtom = atom(get => …)

Evidence

The visibility filter now reads raw node and edge state, so a style edit no longer re-runs it. Display entities for the types on the canvas are still rebuilt on a style edit. The next PR in the stack stops that for every type except the one edited.

Verified live: agent-tested in Chrome against a local Gremlin Server with 10,001 vertex and 10,001 edge types, expanding a hub to 76 nodes. Post-GC heap grew about 0.3 MB per clear-and-expand cycle over 10 cycles and leveled off. Timings for the whole stack are in the PRs stacked above.

Merge Danger

Door: two-way. No saved data or config changes shape.

Impact: rendering. Every Graph View render goes through the shared visible-entity atoms.

Related


🤖 Written by an AI agent on my behalf.

The old family was keyed on a freshly allocated id array, so every node-set change interned an entry nothing could reach again. The existing neighbor tests pin the behavior; retention itself cannot be asserted, because atomFamily exposes no size.

Layer: 1-canvas-pipeline
The canvas map and the array hook went through a family keyed on a freshly allocated Vertex array, so every node-set change interned an entry nothing could reach again. The new tests pin the behavior and pass both before and after; retention itself cannot be asserted, because atomFamily exposes no size.

Layer: 1-canvas-pipeline
@kmcginnes
kmcginnes force-pushed the graph-style-render-performance branch from f30b005 to 8dfa5bf Compare December 1, 2026 19:00
@kmcginnes
kmcginnes changed the base branch from schema-view-style-perf to main December 1, 2026 19:00
@kmcginnes kmcginnes changed the title Take schema-scale style work off the render path, and fix what review found Trim the Graph View render path and debounce the color picker Dec 1, 2026
@kmcginnes
kmcginnes marked this pull request as ready for review December 1, 2026 19:00
@kmcginnes
kmcginnes force-pushed the graph-style-render-performance branch 2 times, most recently from b579e82 to eeaae98 Compare December 1, 2026 22:04
@kmcginnes kmcginnes changed the title Trim the Graph View render path and debounce the color picker Compute the Graph View's visible entities once per change Dec 1, 2026

@kmcginnes kmcginnes left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@kmcginnes
kmcginnes added this pull request to stack #2693 December 1, 2026 22:16
@kmcginnes
kmcginnes merged commit 0eada79 into main Dec 1, 2026
4 checks passed
@kmcginnes
kmcginnes deleted the graph-style-render-performance branch December 1, 2026 22:22
kmcginnes added a commit that referenced this pull request Dec 1, 2026
)

## Summary

Editing one type's style built new style, type config, and display
objects for every type in the schema. On a 10k-type schema that cost
about 76 ms of store work per edit.

**User-facing:** the Data Explorer's Display Name and Display
Description selects show the attribute the table actually uses, as the
node style dialog already does. Style edits on large schemas are faster.

```diff
 setVertexStyle(A)
-  vertexStyleAtom            → new lookup; every type's resolved style is a new object
-  mergedConfigurationSelector → re-merges user styles into every type config, re-sorts
-  every displayVertexTypeConfigSelector, every displayVertexSelector re-runs
+  storedVertexStyleByTypeAtom(A) changes; every other type keeps its object
+  type configs come from the schema only; user styles are read per type at display time
+  display type config rebuilds only when its type's display label changes
+  displayVertexSelector / displayEdgeSelector keyed on VertexId / EdgeId
```

## Evidence

**Before:** a single color edit invalidated every per-type atom. In the
picker trace, Jotai's store update took 76 ms per commit.

**After:** new identity tests check that editing type A leaves type B's
resolved style, type config, display config, and display vertex the same
object. "ignores a display attribute stored on the schema" pins the Data
Explorer selects. Display entities on the canvas keep their identity
when another type's style changes, so the canvas elements are no longer
rebuilt for an untouched type. The family-key tests check that replacing
a vertex or edge with the same id adds no new cache entry. With the
whole stack applied, the store update in the same trace dropped to 37 ms
per commit.

**Verified live:** agent-tested in Chrome against 10,001 vertex and
10,001 edge types. Picking `code` in the Data Explorer's Display Name
select stored it in the user style and relabeled the hub on the canvas.

## Merge Danger

**Door:** two-way. Stored styles keep their shape.

**Impact:** display. Every vertex and edge label and type label reads
styles per type now.

`mergeEdge` drops the legacy rewrite of an edge `displayNameAttribute`
from `"type"` to `"types"`. Old state survives: on `main`, nothing read
the patched value. Edge labels already read the resolved style, which
never had the patch.

Exported connection files no longer include user styles in their schema
entries. Since v2.5.0, import has ignored styles in the file, because
the canvas reads only stored user styles. Only v2.4.0 and older apply
styles from a file, so a file exported from this build shows default
styles there.

## Upgrade Notes

- **The Data Explorer's Display Name and Display Description selects on
SPARQL connections can show a different attribute.** The selects used to
show the schema's guessed attribute. They now show the attribute the
table renders. Nothing to do unless you want a different one.

## Related

- Related to #2116: rekeys `displayEdgeSelector` and
`displayVertexSelector` on ids, so search results and the
`useDisplayVertex` fallback no longer leave a cache entry behind on
every render
- Stacked on #2128

---

<sub>🤖 Written by an AI agent on my behalf.</sub>
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