Skip to content

Pen tool p95 hits 406ms at 50K points #37

@kostyafarber

Description

@kostyafarber

Problem

Pen tool point placement at 50K-point scale takes 82ms p50, 406ms p95 — far over the 16.6ms frame budget. The p95 spike to ~400ms likely comes from GC pressure and full snapshot rebuilds on every click.

Measured via Playwright E2E perf tests (perf.spec.ts) on the real Electron app.

Perf Report (50K points)

Operation p50 (ms) p95 (ms) p99 (ms)
translate-drag (all pts) 2.40 7.90 12.70
pen-tool (100 clicks) 81.90 405.70 407.30

For comparison, draft translate at 50K all-points is 2.4ms p50 — ~34x faster.

Likely Causes

Each pen click at 50K points:

  1. Adds a point to the active contour via the bridge (NAPI call)
  2. Rebuilds the glyph snapshot from Rust
  3. Fires glyph identity signal → triggers React re-renders for sidebar, handles, segments
  4. Records an undo entry with the full command
  5. The p95 spike to ~400ms suggests GC pressure from allocations (50K-point snapshot copies)

Investigation Areas

  • Profile the pen click path to isolate which step dominates
  • Consider batching snapshot rebuilds (dirty flag + next-frame sync instead of immediate)
  • Check if the sidebar/glyph-info components are re-rendering on every point add
  • The ~400ms p95 spike happening consistently suggests a specific expensive operation (full snapshot JSON serialization?) rather than random GC

Files

  • src/renderer/src/lib/tools/pen/ — pen tool behaviors
  • src/renderer/src/bridge/NativeBridge.tsaddPointToContour, snapshot sync
  • src/renderer/src/lib/model/Glyph.ts — reactive model updates

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions