Commit 9399811
authored
perf: Parallelize lockfile parsing with workspace discovery (#11927)
## Summary
- Start reading and parsing the lockfile on a background thread
concurrently with workspace discovery and package.json parsing
- The lockfile read only needs the package manager identity (cheap
string parse from root package.json) and the root package.json — both
available before the package graph pipeline begins
- If the background read completes before `resolve_lockfile`, the result
is injected into the state and the synchronous path becomes a no-op
- Falls back gracefully: if package manager detection fails or the
background read errors, the existing synchronous path runs as before
The package graph build pipeline was:
```
parse_package_jsons → read_lockfile → connect_internal_deps → ...
```
Now:
```
parse_package_jsons ──┐
├→ connect_internal_deps → ...
read_lockfile ────────┘
```
This saves `min(lockfile_parse, workspace_discovery)` off the critical
path.
## Benchmarks
`hyperfine` comparing `faster-and-faster` (Benchmark 1) vs `main`
(Benchmark 2), 10 runs each with 5 warmup runs, `--skip-infer --dry` to
isolate turbo overhead.
**Large monorepo (~1000 packages):**
| Run | faster-and-faster | main | Speedup |
|-----|-------------------|------|---------|
| 1 | 2.053s ± 0.117s | 2.157s ± 0.177s | **1.05x ± 0.10** |
| 2 | 1.959s ± 0.083s | 2.170s ± 0.191s | **1.11x ± 0.11** |
**Medium monorepo (~50 packages):**
| Run | faster-and-faster | main | Speedup |
|-----|-------------------|------|---------|
| 1 | 1.470s ± 0.206s | 1.388s ± 0.064s | 1.00x ± 0.16 (noise) |
| 2 | 1.428s ± 0.071s | 1.436s ± 0.129s | 1.01x ± 0.10 |
**Small monorepo (~10 packages):**
| Run | faster-and-faster | main | Speedup |
|-----|-------------------|------|---------|
| 1 | 1.029s ± 0.021s | 1.048s ± 0.022s | **1.02x ± 0.03** |
| 2 | 1.040s ± 0.039s | 948.8ms ± 33.7ms | 1.00x ± 0.07 (noise) |1 parent 6ef1582 commit 9399811
1 file changed
+46
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| 103 | + | |
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
| |||
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
| 143 | + | |
140 | 144 | | |
141 | 145 | | |
142 | 146 | | |
| |||
149 | 153 | | |
150 | 154 | | |
151 | 155 | | |
152 | | - | |
| 156 | + | |
153 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
154 | 180 | | |
155 | 181 | | |
156 | 182 | | |
157 | 183 | | |
158 | 184 | | |
159 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
160 | 199 | | |
161 | 200 | | |
162 | 201 | | |
| |||
220 | 259 | | |
221 | 260 | | |
222 | 261 | | |
| 262 | + | |
223 | 263 | | |
224 | 264 | | |
225 | 265 | | |
| |||
388 | 428 | | |
389 | 429 | | |
390 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
391 | 436 | | |
392 | 437 | | |
393 | 438 | | |
| |||
0 commit comments