You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(test): eliminate SQLite fsync and real rate-limit backoff wait in tests (#8553)
Profiling queue-lifecycle-guards.test.ts (33.7s) and backfill.test.ts (19.2s)
found two more real per-test costs, confirmed via a CPU profile showing wall
time going to idle (real I/O wait), not compute.
SQLite fsyncs on every autocommit write by default; TestD1Database's clones
are real temp files (needed for the template-clone trick from the earlier
fix), so every app .prepare(...).run() paid a real fsync. journal_mode=MEMORY
+ synchronous=OFF are safe for a throwaway clone unlinked as soon as it's
open -- crash-consistency durability is meaningless for data nothing outlives
the test to read back. Benchmarked: 50 inserts, 13.9ms default vs 0.6ms tuned.
fetchWithGitHubRetry's exponential backoff (500/1000/2000ms real setTimeout)
is legitimate production behavior for a genuine 403/429, but several tests
deliberately drive a fixture through the full retry loop to assert the
resulting sync state, not the delay -- paying the full 3.5s every time.
client.ts gains setGithubRateLimitRetrySleepCapMsForTest(), capping only what
is actually awaited, not rateLimitRetryMs's return value -- its dedicated
pure-function backoff-math test stays untouched and still exercises the real
numbers.
Both wired once, suite-wide, via a new test/helpers/vitest-setup.ts
(vitest.config.ts setupFiles) -- same ...ForTest convention as
clearInstallationTokenCacheForTest, applied automatically so every current
AND future test with this shape benefits without opting in.
queue-lifecycle-guards.test.ts: 33.7s -> 7.2s. backfill.test.ts: 19.2s -> 1.7s.
0 commit comments