Skip to content

DB tests: Istanbul coverage adds ~50% wall time / ~38% CPU to the packages/db suite #2274

Open

Description

@jp-knj

Summary

In packages/db, coverage is on by default (vite.config.ts: coverage: { enabled: true, provider: 'istanbul', include: ['src/**/*'] }), so every local pnpm test run pays for instrumentation. I measured the cost on the full suite:

Run (285 files, 4 workers) Elapsed Total CPU
Istanbul coverage (default) 144 s 507 s
--coverage.enabled=false 96 s 367 s
Difference +48 s (+50%) +140 s (+38%)

Repro

From packages/db:

/usr/bin/time -p pnpm vitest --run --maxWorkers=4
/usr/bin/time -p pnpm vitest --run --maxWorkers=4 --coverage.enabled=false

Environment: Apple M3 Max (16 cores, 128 GB), Node v26.12.0, pnpm 11.1.0.

Goal

Reduce test overhead while keeping the same coverage and checks that CI enforces today. CI collects DB coverage per shard and merges it with vitest --mergeReports in .github/workflows/pr.yml, and that should keep working.

Possible directions (for discussion)

  • Turn coverage off by default for local runs and enable it explicitly in scripts/ci-tests.mjs / CI, so CI coverage doesn't change.
  • Compare provider: 'v8' with Istanbul for overhead and report parity before considering a switch.

I'm happy to do the follow-up PR, with before/after numbers, once there's agreement on a direction.

Activity

  1. jp-knj commented on Oct 28, 2026

    @jp-knj
    ContributorAuthor

    Follow-up: here is where the rest of the cost goes, beyond coverage.

    Method. I ran packages/db with --maxWorkers=4, changing one condition per run. Times are wall time and total CPU (user+sys). I measured on commit 26d38a4cd with Node 26.12.0, on an M3 Max. A repeated run of the same condition matched within 0.02 s. On Node 24.18.0 with origin/main + #2275 (300 files), the coverage cost has the same shape: 122 s / 421 s without coverage, 165 s / 522 s with it.

    Cost Wall CPU Kind
    Istanbul coverage +43–48 s +100–140 s Instrumentation
    tests/oracle-replay.test.ts +20 s +106 s Process startup
    typecheck: { enabled: true } +26 s +35 s tsc
    environment: 'jsdom' for all files +15 s +76 s Environment setup (~75 of 285 files touch the DOM)
    tests/indexed-db/retirement-oracle.test.ts +14 s +8 s Idle waiting, fixed in #2275 (64 s → 2.3 s)

    Notes:

    Next I'm looking at reducing the replay test's process startup without weakening what it checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions