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
The Backend tests and Postgres tests jobs take about 20 minutes each. On a recent green run on main, the unit test step took 950s on SQLite and 1124s on Postgres, and both jobs also waited about 1.5 minutes for the TypeScript drift check before starting.
Findings
About 70% of the unit suite time is spent in hooks, not tests. setupApp runs 423 times, and each boot takes about 0.5s on SQLite and 0.7s on Postgres. On Postgres, each boot also drops and recreates the database.
Seeding hashes passwords at bcrypt cost 10. Across the suite that is about 2500 hashes and 1000 compares, roughly 230s of CPU.
Each boot recompiles every route schema with ajv and fast-json-stringify. That is about 30% of the remaining CPU time.
mocha runs serially on one core, while the runner has 4 vCPUs.
The test jobs wait for the drift check even though they don't use anything it produces.
Proposed changes
Run the forge unit tests with mocha --parallel, with one Postgres database per worker.
Use bcrypt cost 4 under test.
Reuse compiled route schemas across app instances under test.
Stop the test jobs waiting on the drift check. The summary job still requires it.
With these, the unit suite takes about 1 minute on SQLite and about 2 minutes on Postgres locally, down from 8 and 10 minutes.
Possible follow-ups
On Postgres, migrate once per worker and reset the data between boots, instead of recreating the database on every boot.
Activity