Commit b0048b0
authored
perf: Resolve literal input paths via stat instead of glob walk (#11955)
## Summary
When tasks use `$TURBO_DEFAULT$` with additional literal inputs (like
`$TURBO_ROOT$/tsconfig.json`),
`get_package_file_hashes_from_inputs_and_index` was running every
include pattern through `compile_globs` (wax regex compilation) +
`walk_glob` (full directory traversal) — even for literal file paths
that resolve to exactly one file.
This separates literal paths from actual glob patterns. Literals get a
single `symlink_metadata` syscall. Only patterns with metacharacters
(`*`, `?`, `[`, `{`) go through the expensive compile + walk path.
## Impact
On a 630-package monorepo where the `typecheck` task includes
`$TURBO_ROOT$/tsconfig.json`, this eliminates ~990 out of 995 glob
compilations and directory walks.
**Profile data** (`turbo run typecheck --skip-infer --dry --profile`):
| Function | Before | After |
|----------|--------|-------|
| `walk_glob` | 51.5% (721ms) | 5.2% (68ms) |
| `compile_globs` | 28.5% (399ms) | <1% |
| Total spans | 18,148 | 15,164 |
**Hyperfine** (30 runs, `--warmup 10`, `typecheck --skip-infer --dry`):
| Repo | Optimized | Mainline | Ratio |
|------|-----------|----------|-------|
| Large (630 pkgs) | 1.623s ± 0.159s | 1.654s ± 0.168s | 1.02x |
| Medium (120 pkgs) | 821ms ± 66ms | 878ms ± 95ms | 1.07x |
| Small (5 pkgs) | 584ms ± 44ms | 589ms ± 108ms | 1.01x |
**Caveat**: Wall-clock improvement is within system noise on most runs.
The CPU time reduction is real and consistent (User time on the large
repo drops from ~1.96s to ~1.48s, a 25% reduction), but I/O and
system-time variance prevent it from reliably surfacing in hyperfine for
my machine.1 parent ef22b25 commit b0048b0
File tree
2 files changed
+81
-31
lines changed- crates
- turborepo-globwalk/src
- turborepo-scm/src
2 files changed
+81
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
443 | 461 | | |
444 | 462 | | |
445 | 463 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
270 | 275 | | |
271 | 276 | | |
272 | 277 | | |
273 | 278 | | |
274 | 279 | | |
275 | 280 | | |
276 | 281 | | |
277 | | - | |
278 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
279 | 286 | | |
280 | 287 | | |
281 | 288 | | |
| |||
285 | 292 | | |
286 | 293 | | |
287 | 294 | | |
288 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
289 | 314 | | |
290 | 315 | | |
291 | 316 | | |
292 | 317 | | |
293 | | - | |
| 318 | + | |
294 | 319 | | |
295 | 320 | | |
296 | 321 | | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
320 | 327 | | |
321 | 328 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
326 | 358 | | |
327 | 359 | | |
328 | 360 | | |
| |||
0 commit comments