Skip to content

perf(erd): relation painter reuses its Paint, rounded paths and cardinality labels (#1518) - #1685

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
perf/erd-paint-allocations
Oct 17, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
perf/erd-paint-allocations

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1518.

ErdRelationPainter.paint allocated, for every route and every repaint, a Paint, a rounded Path and two laid-out TextPainters (with a TextSpan and a TextStyle each).

  • One Paint per paint() call; its colour and width are set once per pass (others / focused) instead of per route.
  • Rounded paths are cached per ErdRoute in an Expando: a repaint that only changes the focused table or the picked relation (hover, click) keeps the same routes and no longer rebuilds 300 paths.
  • Cardinality labels are only ever 1 and * in at most three colours, so each is laid out once and shared (static cache of 16 entries, disposed and restarted when a theme change brings new colours).

Not measured: pan and zoom do not repaint this painter at all (the InteractiveViewer transforms a layer), so the gain is on focus / hover / pick repaints and table drags, where the router's A* dominates. The erd_open_200 bench scenario does not run yet (#1546), so CI cannot show a number for this. Tests pin that every state (nothing focused, focused table, picked relation, route with one point, more colours than the cache holds) still paints, and shouldRepaint.

@github-actions github-actions Bot added frontend Theme parser epic label: frontend performance Theme parser epic label: performance ui User interface components and widgets P2 Medium priority / Parity & Refactoring labels Oct 17, 2026
@github-actions github-actions Bot added this to the 0.5.0 milestone Oct 17, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit ab84e4c into dev Oct 17, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Theme parser epic label: frontend P2 Medium priority / Parity & Refactoring performance Theme parser epic label: performance ui User interface components and widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant