Repository navigation
Avoid ineffective query-plan test instrumentation on Windows - #7317
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
eventsfull-scan query passes with zero guard findings on unmodified Windows baseline, confirming the existing attribution limitation: baseline Windows proof. The diagnostic printsDELIBERATE 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.eventsfull-scan query fails with the expectedfull-scanfinding and exact source function under the changed guard. The probe was removed afterward.2a31a2745eff30b9575e9de9296bf301cff3b609, including all three Windows server shards and both Linux server shards: https://github.com/get-bb/bb/actions/runs/42716684868.