Skip to content

Keep unchanged types' styles stable when one type's style changes - #2687

Merged
kmcginnes merged 4 commits into
mainfrom
redo-graph-style-render-perf-2-style-identity
Dec 1, 2026
Merged

kmcginnes merged 4 commits into
mainfrom
redo-graph-style-render-perf-2-style-identity

Conversation

@kmcginnes

@kmcginnes kmcginnes commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

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.

 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


🤖 Written by an AI agent on my behalf.

@kmcginnes
kmcginnes force-pushed the redo-graph-style-render-perf-2-style-identity branch from 3e4406b to 17dfe45 Compare December 1, 2026 20:44
@kmcginnes
kmcginnes force-pushed the redo-graph-style-render-perf-2-style-identity branch from 17dfe45 to 22163d0 Compare December 1, 2026 22:04
@kmcginnes
kmcginnes added this pull request to stack #2693 December 1, 2026 22:16
Base automatically changed from graph-style-render-performance to main December 1, 2026 22:22
The families were keyed on entity objects, so every re-derived vertex or edge, and every search result built per render, interned a new entry. The tests assert the family's keys stay bounded when a canvas entity is replaced under the same id.

Layer: 2-style-identity
@kmcginnes
kmcginnes force-pushed the redo-graph-style-render-perf-2-style-identity branch from 22163d0 to e6a475b Compare December 1, 2026 22:22

@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 merged commit fac257e into main Dec 1, 2026
4 checks passed
@kmcginnes
kmcginnes deleted the redo-graph-style-render-perf-2-style-identity branch December 1, 2026 23:06
kmcginnes added a commit that referenced this pull request Dec 1, 2026
## Summary

Graph View built its stylesheet and resolved icons for every type in the
schema, about 10k on large databases, on each style change, even when it
drew 3 types.

**User-facing:** style edits apply in place on both canvases. Nothing
else looks different.

```diff
 Graph View / Schema View
-  useGraphStyles()
-    useAllVertexStyles(), useAllEdgeStyles()       # every schema type
-    useBackgroundImageMap(all)                     # icon lookup for every type
-    → new stylesheet → cy.style(newStyles)         # full re-parse per edit
+  useGraphStyles()                                 # static node[type] / edge[type] mappers
+    mapper(element) → cache.get(type) ?? resolve(type)   # only types Cytoscape draws
+  subscribeStyles(cy)
+    store.sub(user styles), iconRegistry.subscribe
+      → drop changed types → cy.style().update()   # in place
```

## Evidence

**Before:** the picker trace spent 29 ms per commit in `useGraphStyles`
and 26 ms in `cy.style`. Each expand spent 27 ms in `useGraphStyles`.

**After:** both run in 0 ms per commit and per expand, and `cy.style`
takes 6 ms. A test with 200 typed icons and one drawn type resolves one
icon. Icons used for the first time in one style pass go out in a single
registry request: 50 distinct icons make 1 request instead of 50. New
tests cover in-place restyle of a vertex and an edge, a style reset, an
undrawn or removed type leaving the canvas alone, a failed icon not
forcing later restyles, catching up after being unsubscribed, a
late-resolving icon, a type missing from the schema keeping the default
style with no icon as on `main`, and a type that syncs into the schema
restyling.

Medians of 3 runs, dev build, measured before the final icon-batching
and drawn-type changes, 10,001 vertex and 10,001 edge types, 76 nodes on
the canvas, `main` → this stack:

- Picker, longest task per commit: 175 → 65 ms
- Picker, main-thread busy per commit: 264 → 99 ms
- Expand, longest task: 258 → 217 ms
- Expand, main-thread busy: 631 → 662 ms, within run-to-run noise. The
rest is layout and React effects.

Every picker commit still runs past one 16.7 ms frame. The remainder is
Jotai store work (about 37 ms) and React passive effects, which include
re-deriving the edited type's display vertices.

**Verified live:** agent-tested in Chrome against a local Gremlin Server
with 10,001 vertex and 10,001 edge types. Each of these restyled in
place with zero stylesheet rebuilds:

- Vertex shape, color, border, and icon
- Edge line style, color, and arrows
- Clear Customization
- An edit made while Graph View was hidden showed when it came back

Editing an undrawn type caused no canvas work. Schema View drew all
10,001 types, using a grid layout because fCoSE runs out of memory at
this size on `main` too.

## Merge Danger

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

**Impact:** rendering. Every canvas style now comes from the lazy cache.

## Related

- Related to #2658: Schema View at 10k types now crashes in the fCoSE
layout on `main` as well as on this stack
- Related to #2655
- Stacked on #2687

---

<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