Perf tests: Disable Playwright tracing to remove snapshot overhead#78295
Conversation
The shared `@wordpress/scripts` Playwright config sets `trace: 'retain-on-failure'`, which enables Playwright's own tracing on every test. That tracing injects a DOM snapshot recorder (captureSnapshot / visitNode / _getSheetText / etc.) into every page context and fires it on the main thread on each action. In a representative post-editor first-block trace this adds ~750ms of non-Gutenberg main-thread work after the editor mounts, and contributes noise to the interaction metrics (type, focus, click, hover) that measure event durations across actions. Perf measurements don't benefit from Playwright's trace.zip artifacts (we capture our own Chromium trace via `browser.startTracing`), so opt out by setting `trace: 'off'` for the perf suite only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
jsnajdr
left a comment
There was a problem hiding this comment.
Traces are very useful for debugging flaky tests. But it's true that performance tests are quite simple and stable, don't need much debugging. And if it's implemented as an injected script, that's too much intrusion for a perf test.
|
Size Change: 0 B Total Size: 7.96 MB ℹ️ View Unchanged
|
What?
Set
trace: 'off'for the performance test suite.Why?
The shared
@wordpress/scriptsPlaywright config defaults totrace: 'retain-on-failure'. That enables Playwright's own tracing on every test, which is separate from the Chromium tracing we use for perf measurements (browser.startTracinginMetrics).Playwright's tracing injects a DOM snapshot recorder into every page (
captureSnapshot,visitNode,visitChild,_getSheetText,_updateLinkStyleSheetTextIfNeeded). It runs on the page's main thread on each action. In a representative post-editor first-block Chromium trace it accounts for ~750 ms of non-Gutenberg work after the editor mounts and adds noise to the interaction metrics (type,focus,click,hover) that measure event durations across actions.Perf tests don't use Playwright's
.trace.zipartifacts — we capture and analyse our own Chromium traces — so the snapshotter is pure overhead.How?
Override
traceintest/performance/playwright.config.tsso the perf suite opts out without affecting the e2e suite, which still benefits fromretain-on-failurefor debugging.Testing Instructions
firstBlockiteration inpost-editor.spec.jsorsite-editor.spec.js).url: nullmatchingcaptureSnapshot/visitNode/_getSheetText— they should no longer appear.type/focus/ interaction metric values across a few runs; variance should be slightly tighter.Use of AI Tools
Authored with Claude Code assistance; reviewed and verified by the author.