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:
- Adds a point to the active contour via the bridge (NAPI call)
- Rebuilds the glyph snapshot from Rust
- Fires glyph identity signal → triggers React re-renders for sidebar, handles, segments
- Records an undo entry with the full command
- 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.ts — addPointToContour, snapshot sync
src/renderer/src/lib/model/Glyph.ts — reactive model updates
Related
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)
For comparison, draft translate at 50K all-points is 2.4ms p50 — ~34x faster.
Likely Causes
Each pen click at 50K points:
Investigation Areas
Files
src/renderer/src/lib/tools/pen/— pen tool behaviorssrc/renderer/src/bridge/NativeBridge.ts—addPointToContour, snapshot syncsrc/renderer/src/lib/model/Glyph.ts— reactive model updatesRelated