Skip to content

perf(coverage-v8): resolve raw coverage in main process#1501

Merged
fi3ework merged 7 commits into
mainfrom
9aoy/coverage-v8-resolve-raw-main-process
Jul 6, 2026
Merged

perf(coverage-v8): resolve raw coverage in main process#1501
fi3ework merged 7 commits into
mainfrom
9aoy/coverage-v8-resolve-raw-main-process

Conversation

@9aoy

@9aoy 9aoy commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR optimizes V8 coverage finalization on top of the existing AST converter and raw-entry filtering path. Workers now return lightweight raw coverage payloads through collectRaw(), the pool forwards those payloads separately from normal test results, and the main process resolves all raw payloads once through resolveRawCoverage() before report generation. Istanbul keeps the existing worker-side collect() fallback, and slow coverage finalization now shows a processing hint when it takes more than 1s.

Performance on rsbuild with time pnpm test --coverage --coverage.provider v8 --coverage.reporters=json-summary (5-run median):

  • Wall time: 4.35s -> 3.82s (-12.2%, 1.14x faster)
  • Rstest total: 3192ms -> 1581ms (-50.5%, 2.02x faster)
  • User CPU: 29.95s -> 12.87s (-57.0%)
  • Sys CPU: 5.20s -> 3.28s (-36.9%)
  • Coverage summary stayed equivalent: 31.67/21.45/31.79/32.32 -> 31.65/21.45/31.67/32.32

Related Links

#1490

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46d03596ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/coverage-v8/src/provider.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves performance of V8 coverage finalization by shifting AST-based conversion work out of workers and into the main process: workers emit lightweight raw coverage payloads, the pool forwards them separately, and the main process resolves/merges them once before report generation. It also adds a “slow processing” hint when coverage resolution takes noticeable time.

Changes:

  • Add a raw-coverage collection/resolution path (collectRaw() / resolveRawCoverage()) for the V8 coverage provider and validate merging behavior with a new unit test.
  • Plumb raw coverage payloads from worker → pool → main process, resolving them once before report generation.
  • Extend core public types to reflect the new raw-coverage workflow and add lifecycle slow-step messaging.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/coverage-v8/src/provider.ts Introduces raw payload collection + main-process resolution/merge logic; refactors option/source handling for reuse.
packages/coverage-v8/tests/provider.test.ts Adds a test ensuring raw payloads merge before conversion to Istanbul format.
packages/core/src/runtime/worker/runInPool.ts Switches worker coverage collection to prefer collectRaw() with fallback to collect().
packages/core/src/pool/index.ts Adds a dedicated callback path to forward raw coverage results and strips them at the pool boundary.
packages/core/src/core/runTests.ts Collects raw coverage payloads and resolves them once in the main process before reporter/report generation, with slow-step logging.
packages/core/src/types/{coverage.ts,testSuite.ts} Updates public type surface for raw coverage hooks and raw coverage results field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/coverage-v8/src/provider.ts Outdated
Comment thread packages/coverage-v8/src/provider.ts
Comment thread packages/coverage-v8/src/provider.ts
Comment thread packages/core/src/types/testSuite.ts
Comment thread packages/core/src/types/coverage.ts
Comment thread packages/core/src/types/coverage.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread packages/core/src/runtime/worker/runInPool.ts Outdated
Comment thread packages/coverage-v8/src/provider.ts
@9aoy

9aoy commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48a0fd8bf7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/runtime/worker/runInPool.ts Outdated
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 3, 2026

Copy link
Copy Markdown

Deploying rstest with  Cloudflare Pages  Cloudflare Pages

Latest commit: 36d400e
Status: ✅  Deploy successful!
Preview URL: https://2a680a0d.rstest.pages.dev
Branch Preview URL: https://9aoy-coverage-v8-resolve-raw.rstest.pages.dev

View logs

@9aoy

9aoy commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36d400e314

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/coverage-v8/src/provider.ts Outdated
Comment thread packages/core/src/pool/index.ts Outdated
Comment thread packages/core/src/core/runTests.ts Outdated
@9aoy 9aoy requested a review from fi3ework July 6, 2026 03:01
Comment thread packages/core/src/core/runTests.ts
@9aoy 9aoy requested a review from fi3ework July 6, 2026 06:56
@fi3ework fi3ework merged commit e8f7f63 into main Jul 6, 2026
12 checks passed
@fi3ework fi3ework deleted the 9aoy/coverage-v8-resolve-raw-main-process branch July 6, 2026 07:01
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.

3 participants