Repository navigation
test(service-datasource): the pool-support and driver-factory suites run under 10 s (two #23184 rows) - #23711
Conversation
…n the two slow suites datasource-pool-support and default-datasource-driver-factory each paid a cold transform of @objectstack/core's source (the package's vitest alias) inside their first case that builds a real driver: 7-9 s of each file's ~9 s of clocked wall. Module-top side-effect imports of the drivers the cases build move that load into collection, per the clocked-window rule. No case, it/describe line or expect line changes. Claude-Session: https://claude.ai/code/session_017WLmd5in9RXu7AjyHR8fKQ Co-authored-by: Claude <noreply@anthropic.com>
…-ledgered drivers The first cut side-effect-imported driver-memory and driver-mongodb at module top. check:driver-memory-census reds on any new binding of driver-memory (a ruled census), and check:test-source-alias reds on a new unaliased test import of driver-mongodb. Neither is the cost anyway: the 7-9 s is @objectstack/core's source transform, which every driver imports. So the files now preload @objectstack/core plus driver-sql (and driver-sqlite-wasm in the factory suite); driver-memory and driver-mongodb still load in their first case, at 0.2-0.5 s each. Claude-Session: https://claude.ai/code/session_017WLmd5in9RXu7AjyHR8fKQ Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
席位核对
Verdict: ACCEPT at head
Generated by Claude Code |
Refs #23184 (service-datasource rows: datasource-pool-support, default-datasource-driver-factory)
Clause-②: no
Rows answered
Both rows of the card's
@objectstack/service-datasourcelist:src/__tests__/datasource-pool-support.test.ts, listed at 17.6 s (run38294929860);src/__tests__/default-datasource-driver-factory.test.ts, listed at 10.6 s (run38217670691).The pin is the next refresh PR's list: it should name neither file. The card stays open for its other rows: the three remaining
plugin-authrows (org-create-posture-gate, implicit-account-linking, dev-admin-seed-credential-gate) and theplugin-securityandorganizationsrows.The diff is tests only: 5 module-top side-effect import lines and their comments in the two test files, +44 / -0. No production file, option, constant, timeout or export changes. Every
it(,describe(andexpect(line in both files is byte-identical to the base and in the same order.Where the time went
A probe at the base (temporary, deleted; two runs per file, each in a fresh vitest worker) timed every load the files' cases trigger, in the order they trigger them:
@objectstack/core, first load@objectstack/driver-sql(knex)@objectstack/driver-memory, after core@objectstack/driver-mongodb, after core@objectstack/driver-sqlite-wasm, after driver-sqlcreate(), the wasm connect, sync and round tripSo nearly all of each file's clocked wall was one module load. The factory reaches every driver through a lazy
await import(), and every driver imports@objectstack/core. This package'svitest.config.tsaliases@objectstack/coretopackages/core/src/index.ts, so the first case to build a real driver paid a cold vite transform of core's whole source graph inside its clocked window. Indatasource-pool-supportthat wasmemory WITHOUT a pool still builds exactly as before(8.1 s of the file's 9.3 s). Indefault-datasource-driver-factoryit wasbuilds a file-backed SqliteWasmDriver that connects and round-trips(11.4 s of 12.4 s). No case waits on a timer, a retry back-off, an idle or acquire timeout, or a live database. Every postgres, mysql and mongodb case builds a driver without connecting.What changed
Each file now pays that load at module top, in collection, following the AGENTS.md convention that clocked windows measure behaviour, never loading (the clocked-window rule of
check-test-source-alias). The factory's own lazy imports stay where they are; the module cache hands them the instances already loaded.datasource-pool-support.test.ts:import '@objectstack/core'andimport '@objectstack/driver-sql'.default-datasource-driver-factory.test.ts: the same two, plusimport '@objectstack/driver-sqlite-wasm'.Three drivers are left out on purpose, and each still loads inside its first case:
@objectstack/driver-memory(0.2 to 0.5 s once core is loaded): every module binding of it is a ruled census entry. A first cut that imported it here turnedcheck:driver-memory-censusred, because a new binding needs a maintainer ruling.@objectstack/driver-mongodb(0.1 to 0.3 s): this package's tests reach it only through the factory, so a test-file import is a new unaliased artifact import. The same first cut turnedcheck:test-source-aliasred. Aliasing it would change a config file outside this card's surface.@objectstack/driver-turso: the turso missing-package case stages its absence withoutvi.resetModules(), so the factory's own lazy import must be that package's first. Thesqlite-wasmabsence case resets the module registry before it mocks, so loading that package at module top is the same condition the construction suites already created for it.Measurements
Each figure is vitest's per-file duration (JSON reporter
endTime - startTime, the module-line duration the refresh reads):pnpm exec vitest run --maxWorkers=2 FILE --reporter=verbose --reporter=json, inpackages/services/service-datasource, underos-verify-lock, on a shared 4-vCPU box. The final before and after runs were interleaved at the final head, with the before leg being the base file copied to a temporary name (deleted afterwards), so both legs saw the same load.f1e21c4f45alone (load 1.3 to 1.6)a573f9c57a(load 1.6 to 3.0)a573f9c57aThe load is moved, not removed. vitest's whole-file
Duration(collection plus run) is unchanged within noise: pool-support 12.70 / 11.50 / 11.73 s before against 12.05 / 12.18 / 12.38 s after, and driver-factory 12.48 / 13.40 / 13.06 s before against 13.19 / 12.48 / 13.44 s after. Theimportphase grew from about 3 s to about 11 to 12.5 s per file. What the change buys is that no test or hook clock contains a compiler run any more. It does not make the package's test job faster.CI projection. The per-file CI captures of recent hourly runs are NOT MEASURED. The
test-core-timing-tableartifact of hourly run38773780951redirects toproductionresultssa5.blob.core.windows.net, which this container's egress proxy refuses (CONNECT 403). The ratios therefore come from the card's own readings against the interleaved before medians: pool-support 17.6 s against 8.58 s is a ratio of 2.05, which projects to 1.25 s; driver-factory 10.6 s against 9.39 s is 1.13, which projects to 0.85 s. At a 4.0 ratio, the worst post-landing ratio an earlier slice of this card read, they project to 2.4 s and 3.0 s.Proof that every case still runs and still asserts the same
it(/it.each(/describe(/expect(lines are byte-identical to the base and in order: 72 / 0 / 8 / 177 for pool-support, and 45 / 1 / 10 / 105 for driver-factory.expect.getState().assertionCallsper case, at the base and at the head. The per-case counts are identical: 210 assertions over 72 cases, and 128 over 50 cases. No case asserts nothing.@objectstack/core,@objectstack/driver-sqland@objectstack/driver-sqlite-wasmimported at module top, the factory'ssqlite,postgres,mysqlandsqlite-wasmdrivers are eachinstanceofthe class the test file imported (4 of 4). The first memorycreate()then took 241 ms, against 8 s with core not yet loaded.Tests and gates (final head
a573f9c57a)pnpm --filter @objectstack/service-datasource run typecheck: exit 0.tsc --listFilesOnlylists both changed files in the package's program.@objectstack/service-datasourcesuite with--maxWorkers=2: 45 of 45 files, 838 of 838 tests passed.--no-inline-config: exit 0. The control-byte scan of both files found 0 hits.skip-changeset: the package shipsdist,README.mdandCHANGELOG.md. The comment marker of this change has 0 hits in its builtdist, and the positive controlcreateDefaultDatasourceDriverFactoryhas 4.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 52 commands, the same 52 as the seat's lead. All 52 exit 0 ata573f9c57a, each run separately with the exit code captured before any pipe, and--ranreports 52 derived, 52 run, 0 NOT-MEASURED and 0 UNRUN.check:dual-build-cjs-loadsran after a fullturbo run build(75 of 75 tasks). A first sweep at the first cut (ab97ec143f) hadcheck:driver-memory-censusandcheck:test-source-aliasred, which is what narrowed the import list (above); every other family was green there too.check:engine-double-contractprinted its repo-wide census line verbatim:UNRECOGNISED [engine-double-contract]: 22 construct(s) in packages, examples declare a scanned verb (delete, update, findOne) alongside engine siblings, and this gate could not read the implementation -- so they are in NEITHER the pinned population nor the ledger.Its output names neither changed file, and this diff adds no construct.Acceptance notes
@objectstack/core's source is paid by every test file in this package whose cases load a driver, once per worker, because the package's vitest config aliases@objectstack/coreto source. The alias is the intended repair ofcheck:test-source-alias, and that gate's header names aliased dependencies as outside its clocked-window population ("widening the population is a different card"), which is also why the gate was green over these two files at69351e985a(measured, exit 0). This is an observation, not a defect, and no carrier is named.vitest.config.ts. The config'stestTimeoutcomment citessqlite WITHOUT a poolas about 1.1 s idle, paying the driver-sql import. After this change that case runs in 28 to 43 ms. The 60 s timeout itself is untouched (no timeout was raised or lowered), and the comment is outside this card's surface. Noted, not filed.Generated by Claude Code