perf: Eliminate redundant syscalls in FSCache fetch and exists (#11985)
## Summary
- In `fetch()`, replace the `exists()` + `CacheReader::open()` two-step
with a single `open()` attempt — 1 syscall instead of 3 on cache hits
- Remove the legacy uncompressed `.tar` fallback from both `fetch()` and
`exists()` — `put()` has written `.tar.zst` exclusively since the
Go-to-Rust port in mid-2023
- Cache misses drop from 2 syscalls to 1
## Why
Every `fetch()` call was doing: `stat(.tar)` → ENOENT → `stat(.tar.zst)`
→ OK → `open(.tar.zst)` — 3 syscalls. The new flow is `open(.tar.zst)` →
done. The uncompressed `.tar` path was a fallback for artifacts from the
Go era (~2021-2022). No modern Turborepo version writes uncompressed
cache artifacts, and cache entries rotate out constantly.
## Benchmark Results
Benchmarks run on a Linux sandbox with hyperfine (15 runs, 2 warmup),
all cache-hit scenarios.
| Repo Size | Baseline (mean) | Improved (mean) | Change |
|-----------|----------------|-----------------|--------|
| ~1,000 packages | 1.536s ± 0.130s | 1.439s ± 0.037s | **97ms faster
(6.3%), 71% less variance** |
| ~125 packages | 615.6ms ± 136.7ms | 558.5ms ± 23.3ms | **57ms faster
(9.3%), 83% less variance** |
| 5 packages | 72.1ms ± 21.9ms | 82.3ms ± 36.4ms | noise (min times
identical at ~55ms) |
Profile data for the large repo shows `fetch` self-time dropped from
**200.5ms (11.8%) to 129.6ms (8.0%) — a 35% reduction** across 962
calls.
Note: benchmarks were taken before the legacy removal (which had the
fallback still present but checked second). The legacy removal makes
misses 1 syscall instead of 2, which won't show in cache-hit benchmarks
but helps cold-start scenarios.
## Breaking Change
Removes support for reading uncompressed `.tar` cache artifacts. These
haven't been written since ~2022 (Go era). Any user who somehow still
has uncompressed artifacts in their local cache can clear it with `turbo
daemon clean` or by deleting `node_modules/.cache/turbo`.