Skip to content

Avoid ineffective query-plan test instrumentation on Windows - #7317

Merged
ymichael merged 1 commit into
mainfrom
ci/nov9-windows-query-guard
Nov 9, 2026
Merged

ymichael merged 1 commit into
mainfrom
ci/nov9-windows-query-guard

Conversation

@ymichael

@ymichael ymichael commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The query-plan test guard formats and parses a stack for every prepared SQLite statement on Windows, although its POSIX-only attribution cannot identify Windows callers. This unsupported-platform limitation was documented in #7302, and the bundled attribution test already skips Windows. The work consumes time without producing findings or query-function coverage there.

What changed

Return an empty test guard on Windows before patching SQLite's prepare method. This is a three-line test-support change in packages/db/src/query-plan-test-guard.ts; its callers are the database and server test setup files. Runtime query auditing and Linux/macOS test auditing and function-coverage reporting are unchanged. No test or assertion is removed. Windows attribution remains unsupported; enabling it later must include this platform gate.

How you verified

  • Same-runner Windows ABBA comparison of the four slow server files passed every round (137 tests passed, five existing platform skips): diagnostic run. Baseline wall times were 90.22/68.09 seconds; candidate 62.68/54.48 seconds. Average 79.16 → 58.58 seconds, a 20.58-second (26%) reduction for this four-file invocation, not a claim about total CI time. Both candidate rounds beat both baseline rounds despite machine/warmup variation.
  • The same deliberate real events full-scan query passes with zero guard findings on unmodified Windows baseline, confirming the existing attribution limitation: baseline Windows proof. The diagnostic prints DELIBERATE FULL SCAN win32 []. Earlier instrumentation also observed 611 and 1,406 prepares with zero attributed callers; that initial run had diagnostic temp-path failures and is excluded from timing claims.
  • On macOS, a temporary real events full-scan query fails with the expected full-scan finding and exact source function under the changed guard. The probe was removed afterward.
  • Existing query-plan auditor tests and database typecheck pass through Turbo; formatting and diff checks pass. Independent review found no issues. Normal final-head CI is green at 2a31a2745eff30b9575e9de9296bf301cff3b609, including all three Windows server shards and both Linux server shards: https://github.com/get-bb/bb/actions/runs/42716684868.

AGENT GENERATED

@ymichael
ymichael merged commit a96a8ee into main Nov 9, 2026
35 checks passed
@ymichael
ymichael deleted the ci/nov9-windows-query-guard branch November 9, 2026 23:08
ymichael added a commit that referenced this pull request Nov 10, 2026
#7323)

## Human comments

## What was wrong

The query-plan test guard formats an `Error.stack` for every prepared
SQLite statement, then parses it to identify the query's owner and
record function coverage. CI's coverage mode captures 40 frames, making
this repeated instrumentation expensive in database and server tests.
The recently failing 15-second pruning case belongs to one of the
affected randomized suites; that incident was not conclusively
reproduced, so this PR improves its execution margin without claiming
every timeout is fixed.

## What changed

Use Node's `util.getCallSites` to capture function names and script
paths without invoking stack formatting, then feed the same attribution
parser at the same stack depth. This API is available throughout the
supported Node range. The changed function is called only by the test
guard; runtime auditing retains its existing `captureStack` path.

No SQL-only caller cache, global `Error.prepareStackTrace` override,
dependency/cache invalidation change, test deletion, timeout increase,
or seed/step reduction. The Windows bypass from #7317 remains unchanged.

## How you verified

- Controlled Linux 4-vCPU ABBA: [run
42722011978](https://github.com/get-bb/bb/actions/runs/42722011978). All
61 focused tests pass every round. Combined pruning plus two timeline
invocations average **61.77 → 34.30 seconds**, saving **27.47 seconds
(44%)**. The 12-case pruning file's test-body time averages **33.69 →
15.81 seconds**. Both candidate rounds beat both baseline rounds; runner
variation was visible, so these are focused invocation measurements, not
a promise about total CI time.
- The same runner's full report comparison passes **710 DB tests and
4,023 server tests**, with one existing skip, under both variants. Whole
DB/server Turbo execution: **216.169 → 186.272 seconds** (29.897 seconds
saved). This is one baseline-then-candidate pair, separate from the
controlled focused ABBA result.
- Both full reports pass the real nightly checker: all **362 required
query functions** execute, and the **14 unique finding objects match
exactly**. Raw function records are not byte-identical: 580 unique keys
become 570 because the formatted stack produces 10 redundant
`Module.foo` aliases. Every corresponding canonical `foo` entry exists
in both reports; canonical function sets match exactly. The focused
ABBA's 109 recorded function entries match exactly in all four rounds.
- A dual-capture diagnostic compared old/new attributed caller and frame
arrays for every query in all eight 400-step pruning seeds: zero
differences.
- An independent reviewer injected the same deliberate unindexed
`events` scan under baseline and candidate. Both fail through the
existing guard's `afterAll` with the exact `full-scan/events` finding
and source function. Probe files were removed and the candidate restored
byte-for-byte.
- Existing query-plan auditor tests, DB typecheck, type-aware lint,
formatting, and diff checks pass. Normal final-head PR CI is green at
`5bfa441b3347e026713636d2d54623d1f4f58103`:
https://github.com/get-bb/bb/actions/runs/42723382923. The real Linux
packages-host job reran the DB tests (cache miss); the previously
timed-out seed 1 passed in 3.899 seconds under the unchanged 15-second
deadline, and all eight seeds passed in 2.019–3.899 seconds.

> AGENT GENERATED
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