turborepo
b0048b03 - perf: Resolve literal input paths via stat instead of glob walk (#11955)

Commit
1 day ago
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.
Author
Parents
Loading