Skip to content

docs(research): wrapped-text filter perf-fix investigation — hotspot identified, fix queued#145

Merged
blove merged 1 commit into
mainfrom
wrapped-text-filter-perf-fix
May 18, 2026
Merged

docs(research): wrapped-text filter perf-fix investigation — hotspot identified, fix queued#145
blove merged 1 commit into
mainfrom
wrapped-text-filter-perf-fix

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 18, 2026

Summary

First flame-graph diagnostic using the new CDP-tracing harness (PRs #143 + #144). Identifies getEstimatedRowHeightSignature (`packages/renderer-dom/src/create-renderer.ts`) as the leading user-code hotspot at ~1.6–2.0 ms self-time (~2% of the 95 ms sample window).

Verdict: no production code change. A speculative "lazy-signature" fix attempted in this session made the metric worse (1.9 ms → 2.6 ms) because columns-ref instability during the run multiplies the signature cost — reverted. The investigation queues a follow-up that targets columns-ref stability at the grid-core boundary.

What ships

File Purpose
`scripts/analyze-cdp.mjs` CDP-trace analyzer; aggregates self-time per V8 call frame, resolves minified names via Vite sourcemap
`apps/bench/vite.config.ts` `build.sourcemap: true` so future traces have function-level attribution out of the box
`docs/research/2026-05-16-...md` Research memo: method, top-30 hotspot table, root-cause refinement, failed-fix postmortem, follow-up roadmap
`package.json` / `pnpm-lock.yaml` `source-map` devDep for the analyzer

Top hotspot (sourcemap-resolved, n=1 baseline)

```
Total sample time: 87.82 ms

41485μs (47.2%) (program) native overhead
11847μs (13.5%) (idle) paint-wait
3903μs ( 4.4%) get clientWidth forced reflow
1911μs ( 2.2%) getEstimatedRowHeightSignature ← leading user-code hotspot
1540μs ( 1.8%) (anon) packages/react/dist/index.mjs:29
1063μs ( 1.2%) (garbage collector)
927μs ( 1.1%) W6 packages/core/dist/index.mjs:69
```

Why no fix shipped

The trace surfaces the hotspot but not a confident single-line fix. The leading hypothesis — that the per-row signature cost is wasted because `cached.columnsRef === columns` should hit the fast path — would only matter if columns ref were stable, which the trace suggests it isn't. Fixing that root cause (likely in `packages/grid-core/src/create-grid-core.ts` where `options = { ...options, columns: nextColumns }` may fire spuriously) needs more instrumentation than fits one PR. Better to ship the tooling + honest analysis than a guess.

What's NOT in this PR

  • Any change to `packages/` production code.
  • Sort + filter-metadata profiling (same code path; deferred until ref-stability fix lands).
  • Matrix-runner CDP integration.
  • Speedscope export.

Gates

  • `pnpm -w typecheck` — passes
  • `pnpm -w test` — 191 / 191 pass
  • `pnpm -w lint` — passes
  • `pnpm format` — clean
  • Quality wedge untouched (no `packages/` source changes)

Follow-up

A separate PR after this lands should: add a counter probe to `estimateRowHeight` confirming how often the slow path fires, find the grid-core mutation that emits a new `options.columns` reference during filter trigger, and stabilize it. Expected delta: 1–2 ms on filter-text / sort / filter-metadata — enough to bring all three under the 16 ms budget.

🤖 Generated with Claude Code

…hotspot identified, fix queued)

First flame-graph diagnostic using the new CDP-tracing harness
(PRs #143 + #144). Identifies getEstimatedRowHeightSignature as the
leading user-code hotspot (~1.6-2.0 ms self, ~2% of trace window).
Speculative lazy-signature fix tried in this session made the metric
worse because columns-ref instability multiplies the signature cost
— reverted. Memo queues a follow-up that targets the columns-ref
stability at the grid-core boundary.

Ships:
- scripts/analyze-cdp.mjs — sourcemap-resolving CDP-trace analyzer
- apps/bench/vite.config.ts — build.sourcemap: true for attribution
- source-map devDep
- research memo

No production code change. Quality wedge untouched.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pretable Ready Ready Preview, Comment May 18, 2026 6:01pm

@blove blove enabled auto-merge (squash) May 18, 2026 18:01
@blove blove merged commit 8707a22 into main May 18, 2026
11 checks passed
@blove blove deleted the wrapped-text-filter-perf-fix branch May 18, 2026 18:04
@github-actions
Copy link
Copy Markdown
Contributor

Vercel preview ready

Preview: https://pretable-pfliq8g53-cacheplane.vercel.app
Commit: b1f2e3ddb41b7bb022ed9a07a58217c42b546434

Updated automatically by the deploy-preview job.

blove added a commit that referenced this pull request May 18, 2026
…o PR #145 (#146)

Adds three performance.mark calls to bench-runtime (interaction.start,
.firstFrame, .settled) and `blink.user_timing` to the CDP categories
list, so traces include the interaction window bounds. Extends
scripts/analyze-cdp.mjs with --window=interaction|settle|full;
default remains full for backwards compat.

Findings: with interaction-window slicing, the leading hotspot for
filter-text / S2 / hypothesis is `matchesFilters`
(packages/grid-core/src/derived-rows.ts:73) at ~800μs / 15% of the
6.97 ms interaction window. PR #145's `getEstimatedRowHeightSignature`
hypothesis was a full-trace artifact dominated by initial-mount work
(3000-row cache fill). Correction memo at
docs/research/2026-05-16-bench-cdp-window-slicing-correction.md
queues the lowercase-cache fix as a clean follow-up.

No production code change. Quality wedge untouched.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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