Skip to content

page.perf: in-page performance probe as a conciv page tool (frames, LoAF, shadow-piercing mutation attribution) #557

Open

Description

@omridevk

Origin: the widget streaming perf effort (PRs #546 #547 #549 #550 #553, plus #554 #555). Everything below is grounded in what that effort actually needed; nothing speculative.

Question

Should the in-page probe that drove the perf lane become a first-class page.* tool, so an agent
debugging jank in a conciv-hosted page gets attribution in one call instead of hand-rolling it?

Evidence it would have paid off

Time accounting of the lane, roughly: ~60% of the probe work was page.evaluate glue that ran
inside the page (rAF frame histogram, MutationObserver over every shadow root with per-container
and per-attribute attribution, LoAF capture with script attribution, window-error capture). The
decisive attribution leaps all came from that data:

Shape (extends the page extension, same patterns it already uses)

The page extension already has page.track (action: start | report, React renders),
page.console (buffered, since), page.inspect, page.dom, page.eval. page.perf slots in
as category read, same start/report action pattern as track:

  • page.perf {action: 'start'}: install the probe (idempotent). Records: rAF frame deltas,
    long-animation-frame entries with script attribution (Chromium only; report unsupported on
    other engines, never silently empty), MutationObserver over document + every open shadow root
    (added/removed/characterData/attribute counts, removed-node kinds, per-container churn, attribute
    writes keyed by attr @ tag.class/[data-scope/part], WeakSet re-insertion counter), window
    error events and console errors/warnings, JSHeap/Nodes samples when the engine exposes them.
  • page.perf {action: 'report', since?}: frame percentiles (p50/p90/p99/max, count over 16.7ms),
    long frames with attribution, mutation totals + top churn containers + top attribute bags,
    re-insertion count, errors, memory peaks. Windowed by since so a caller can bracket a turn.
  • page.perf {action: 'reset'}: zero the counters without reinstalling (the rig needed this at
    send-time so pre-turn warmup does not bill to the turn).

Source to start from: the perf lane's Playwright rig probe (an addInitScript installing window.__perf + a shadow-root-walking MutationObserver), which is already the start verb; the rig's post-processing (percentiles, toggle-window slicing) is report. Omri has the rig locally (gitignored scratch).

What it does NOT do (and must say so)

  • It does not drive a turn. Measuring a real streaming turn still needs a driver (the rig, or the
    user acting). The tool is the probe inside the driver, not the driver.
  • It does not replace engine-specific profiling (Firefox profiler, CPU profiles); it is the
    first-hop attribution that decides whether those are needed.
  • It cannot see the feel. The clip-path collapse measured best in toggle windows and was rejected
    on feel; Recorded so nobody optimizes into that hole again.

Capture hygiene that must ship WITH the tool (else it measures phantoms)

Measurement traps all hit during the lane:

  1. Agent-launched vite dev hosts: Vite 8 forwardConsole auto-on + devtools console pipe echoed
    console errors unboundedly (PR fix: dev hosts no longer echo-loop console.error under agent env #554 fixed the config; until every host has it, scrub
    CLAUDECODE/CLAUDE_CODE/AI_AGENT or the probe's error counts are garbage).
  2. Host pages that inline the widget bundle must declare utf-8 or the inline shiki worker mojibakes
    and highlighting is silently off in every browser (perf(ui-kit-chat): warm shiki grammars off the main thread #549 host tests).
  3. Window at the right moment: reset at send, not at composer-ready.
  4. Turn-length variance: compare ratios and per-second rates, never raw totals, across live turns.
  5. Devtools overlays (TanStack devtools) pollute LoAF attribution on dev hosts; measure verdicts on
    the prod bundle, attribute on the dev host.

Acceptance

  • page.perf start/report/reset exists in packages/extensions/page, schema-validated, real
    browser tests (Playwright, shadow-root traversal proven with the widget's own shadow roots).
  • Unsupported capabilities are reported as unsupported, never as zeros.
  • The perf rig is rewritten to call the tool's probe (one copy of the probe, not two).
  • Tool description carries the hygiene notes in one line each so the agent reads them at use time.

Out of scope

CI perf gating (separate effort), always-on monitoring, Firefox-side LoAF equivalents.

Activity

  1. added
    enhancement
    on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions