How we went wrong

Every change to Otto waits on the test suite before it lands. At the start of this audit the suite took 8 minutes 43 seconds on an 8-core machine: 572 files, 5,766 tests. Typecheck, file-length checks and the build together took about 50 seconds, so the tests were roughly 90% of the wait. We set out to find why, and mostly found our own habits.

What was slow

Summed over the workers, the suite spent 1,728 seconds running tests. Three things explained most of it.

What we got wrong

We never measured. The default five-second timeout turned the cold-import cost into occasional flakes, and we treated them as flakes instead of asking why a test took five seconds. Nobody profiled the loops of thousands of renders. Four tests depended on the machine they ran on (file-creation mask, git identity), and a second test configuration for our mobile app was outside both the default run and CI, so 37 files were never run.

What fixed it

No product code changed, and the test count stayed identical at 5,766.

The result

The suite now takes 5 minutes 8 seconds instead of 8:43. Summed test time fell from 1,728 to 875 seconds, about half, on a shared machine that was no quieter than for the first measurement. Same files, same tests, same four environmental failures that the follow-ups later fixed.

What we keep

A convention written to solve one problem should say what it costs. Look at a test's duration when it times out. Profile anything that loops thousands of times. And a test should set the conditions it needs instead of trusting the machine.

All posts