Repository navigation
perf(kit): record component performance only while Timeline is open - #1209
Open
webfansplz wants to merge 2 commits into
Open
webfansplz wants to merge 2 commits into
webfansplz wants to merge 2 commits into
Conversation
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.
✅ Deploy Preview for vue-devtools-docs canceled.
|
commit: |
There was a problem hiding this comment.
🟡 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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Follow-up to #1206, which covered the closed panel. In development, Vue emits
perf:start/perf:endhook 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:
pagehide, so this also works while another client stays connected.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:
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.pnpm lint && pnpm test && pnpm typecheck && pnpm buildand the Chrome smoke tests pass.