Skip to content

perf(run): gate Playwright tracing behind PARITY_TRACE=1 - #176

Merged
JonasJesus42 merged 1 commit into
mainfrom
perf/trim-html-and-optional-tracing
Jul 29, 2026
Merged

perf(run): gate Playwright tracing behind PARITY_TRACE=1#176
JonasJesus42 merged 1 commit into
mainfrom
perf/trim-html-and-optional-tracing

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

newContext() (src/engine/browser.ts) starts Playwright tracing with { screenshots: true, snapshots: true } whenever tracesDir is passed, and run.ts always passed it. That trace buffer accumulates inside the Chromium process for the entire flow sequence (purchase-journey deadline is 420s) across up to 4 concurrent BrowserContexts — a real, sustained memory cost during every run.

Nothing in the report or the checks reads the trace content — the .zip is a human debugging artifact (Playwright trace viewer) only. So the default run pays the memory/disk cost for something almost never consumed.

Fix

Gate tracing behind PARITY_TRACE=1:

  • run.ts only passes tracesDir (and only writes/stops the trace zip) when the env var is set.
  • Default runs create contexts with tracing off — no per-context snapshot buffer.

To capture a trace for debugging: PARITY_TRACE=1 parity run ....

Verification

  • bun run check (tsc) passes.
  • With PARITY_TRACE unset, <runDir>/traces/ stays empty; with PARITY_TRACE=1, the <viewport>-<side>.zip traces are written as before.

Note

The plan also considered freeing PageCapture.html after checks (#5), but the report's section extraction and many checks read capture.html through report generation, so trimming it isn't safe without moving HTML to disk — deferred. This PR ships the safe, isolated tracing win.

Part of the memory-pressure / OOM series (see #173, #174, #175).

🤖 Generated with Claude Code


Summary by cubic

Gate Playwright tracing behind PARITY_TRACE=1 so default runs skip tracing, avoiding per-context snapshot buffers and trace zips. This reduces sustained memory use during flows.

  • Migration
    • To record traces for debugging: PARITY_TRACE=1 parity run ...

Written for commit 919f5bc. Summary will update on new commits.

Review in cubic

newContext() started tracing with { screenshots: true, snapshots: true } for
every side×viewport context whenever tracesDir was set, and run.ts always set
it. That buffer accumulates in the Chromium process for the whole flow
sequence (up to 420s) across up to 4 concurrent contexts — a real memory cost.
Nothing in the report or checks reads the trace; it's a human debugging
artifact only.

Only enable tracing (and write the trace zip) when PARITY_TRACE=1. Default
runs no longer pay the memory/disk cost.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JonasJesus42
JonasJesus42 merged commit c994804 into main Jul 29, 2026
2 checks passed
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