Skip to content

perf(kit): record component performance only while Timeline is open - #1209

Open
webfansplz wants to merge 2 commits into
mainfrom
perf-timeline-page-recording
Open

webfansplz wants to merge 2 commits into
mainfrom
perf-timeline-page-recording

Conversation

@webfansplz

@webfansplz webfansplz commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #1206, which covered the closed panel. In development, Vue emits perf:start / perf:end hook events around every component render and patch. With a panel open, the kit processed all of them on the page's main thread, even when the Timeline was not open, and the 500 events/s limit then dropped most of them.

Component performance is now recorded only while a client has the Timeline page open:

  • Client: reports when the Timeline page opens or closes, and resends the current state on every refresh (connect, reconnect, page reload, frame switch). An undelivered report is retried until the client disconnects.
  • Kit: tracks the state per client and records while any of them has the page open. Reports carry a revision, so a late "closed" cannot override a newer "open". The state is cleared once all clients disconnect. A panel that closes or reloads reports it on pagehide, so this also works while another client stays connected.
  • Hook: perf events nobody uses return before normalization. Update highlighting and Vapor update detection still receive theirs.

In the extension, a frame the panel switched away from is detached by #1208, which clears its state.

Behavior change: the Performance layer no longer contains renders from before the Timeline page was opened. Collapsing the dock while on the Timeline keeps recording. Other layers are unchanged.

Results

Local benchmark (not included): Vue 3.5 in happy-dom, 5,000 components re-rendering, panel open but not on the Timeline. Time per round over an empty hook, three interleaved runs:

  • Before: 11.4 / 11.1 / 12.6 ms
  • After: 1.5 / 1.8 / 1.3 ms

Testing

  • timeline-page-open.test.ts: open and close, stale reports, several clients, disconnects, highlighting, and Vapor updates.
  • timeline-page-sync.test.ts: retries of both states, no retry after a disconnect, and reporting to a runtime that connects later.
  • Existing performance-layer tests now open the Timeline page first.
  • Manual browser runs, together with the extension disconnect fix: the Vite dock (collapse and expand, rapid tab switching, panel and host reload, closing one of two connected panels) and the extension panel page opened in a tab (page reload and navigation, frame switching, close and reopen).
  • pnpm lint && pnpm test && pnpm typecheck && pnpm build and the Chrome smoke tests pass.

Vue emits several perf hook events for every component render. With a panel
open, the kit processed all of them on the page's main thread even when nobody
was looking at the Timeline.

- The client reports whether its Timeline page is open, resends the state on
  every refresh, and retries an undelivered "open".
- The kit tracks the state per client, ignores stale reports, and forgets it
  once all clients disconnect.
- Unused perf events return at the hook. Update highlighting and Vapor update
  detection still receive theirs.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 10:25
@netlify

netlify Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vue-devtools-docs canceled.

Name Link
🔨 Latest commit 8239089
🔍 Latest deploy log https://app.netlify.com/projects/vue-devtools-docs/deploys/6b0ff4f508fa369b4808f867

@pkg-pr-new

pkg-pr-new Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vue/devtools-agent@1209
npm i https://pkg.pr.new/@vue/devtools-api@1209
npm i https://pkg.pr.new/@vue/devtools-kit@1209
npm i https://pkg.pr.new/vite-plugin-vue-devtools@1209

commit: 8239089

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Failed close reports, client disconnects, and frame switches can leave stale Timeline state, causing component performance recording to remain enabled unnecessarily.

3 open issues
What changed in this PR

Reduces component-performance overhead by recording only while a client has Timeline open, extending the earlier closed-panel optimization.

Changes:

  • Tracks Timeline visibility per client with revision ordering and open-report retries.
  • Skips unused performance hooks while preserving highlighting and Vapor updates.
  • Adds lifecycle tests and documents the recording behavior.
File Description
tests/​unit/​runtime/​timeline-rate-limit.test.ts Opens Timeline before performance tests.
tests/​unit/​runtime/​timeline-page-open.test.ts Tests recording gates and client state.
tests/​unit/​runtime/​timeline-admission-equivalence.test.ts Aligns recording setup with legacy behavior.
tests/​unit/​client/​timeline-page-sync.test.ts Tests retries and delayed connections.
packages/​kit/​src/​runtime/​timeline.ts Tracks page state and gates performance recording.
packages/​kit/​src/​runtime/​runtime.ts Checks performance consumers and resets page state.
packages/​kit/​src/​runtime/​handlers/​timeline.ts Validates page-state commands.
packages/​kit/​src/​protocol/​requests.ts Defines the page-state command payload.
packages/​kit/​src/​hook/​install.ts Drops unused performance hooks before normalization.
packages/​client/​src/​pages/​timeline.vue Reports Timeline lifecycle changes.
packages/​client/​src/​composables/​devtools-timeline.ts Synchronizes page state and retries open reports.
packages/​client/​src/​composables/​devtools-client.ts Resends page state during refresh.
docs/​getting-started/​features.md Documents when performance recording occurs.

Review effort: Balanced

Comment thread packages/kit/src/runtime/runtime.ts Resolved
A lost "closed" report kept the runtime recording component performance until
the next refresh. Retries stop on disconnect, where they would open a new
connection.
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.

2 participants