Skip to content

Commit 216d9bc

Browse files
committed
docs(dev): record the measured cost and concurrency behaviour of cache pruning
Stress-tested the maintenance path rather than assuming it is free. Cost: the size walk is ~30ms on a real cache and ~85ms at 2,000 files — under 2% of a 4.2s warm restart, and invisible against a cold one. It runs before every dev start, so it needed to be cheap; it is. Concurrency: pruning while a dev server is live (which happens when a second server is started from the same checkout) does not crash it. The running server keeps its in-memory state and kept serving HTTP 200 with zero panics. It does stop persisting for the rest of that session, so its next start is cold once — verified recovering at 23.4s then 4.5s. Worth writing down because the directory silently never reappears mid-session, which looks like a bug if you go looking. The cap is a backstop, not routine: a normal session sits at 1-2 GB against a 20 GB default.
1 parent 2f02f2b commit 216d9bc

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

scripts/prune-turbopack-cache.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
*
2525
* Override the cap with `SIM_TURBOPACK_CACHE_MAX_GB` (default 20).
2626
*
27+
* The cap is a backstop, not routine maintenance. A normal session's cache sits
28+
* around 1-2 GB; the 78 GB case was a month of accumulation while the feature was
29+
* effectively abandoned. Measured cost of the size walk: ~30ms on a real cache,
30+
* ~85ms at 2,000 files — under 2% of a warm restart.
31+
*
32+
* Safe to run while a dev server is live, which happens if a second server is
33+
* started from the same checkout: the running server keeps its in-memory state
34+
* and continues serving (verified — no crash, no corruption). It does stop
35+
* persisting for the rest of that session, so its *next* start is cold once, then
36+
* back to normal. Nothing to clean up.
37+
*
2738
* Note for anyone benchmarking the cache: stop the dev server with SIGINT, not
2839
* `kill -9`. Turbopack discards a partially-written cache and rebuilds silently,
2940
* so a hard kill makes a real cache win read as no win at all.

0 commit comments

Comments
 (0)