Repository navigation
Conversation
Metro review: Looks goodRisk: low · Commit: Since the last review, the PR keeps the early return in No findings. Verified
Benchmarks (base vs this PR)
Method
Not run: The description's cold-start benchmark was not repeated. The early return it measures is in the stack base commit (274335a), not in this PR's own diff, and the diff's only per-file change was benchmarked directly. Nothing in the diff is specific to Windows, so no Windows run was needed. Automated review by Claude. Advisory only: it never approves or blocks, and a maintainer makes the call. |
With lazy SHA-1s (Metro's default), a file only needs a worker at startup if a plugin computes data for it as it's crawled. With Metro's defaults none does, since #2220 leaves out the Haste plugin without Haste config. Even so, `processBatch` goes through every crawled file to find that out, checking its path for `node_modules` and building an array of the plugins to run on it. This returns straight away when there's no SHA-1 to compute and every plugin's worker is lazy (`lazy: true`, ie it computes data on demand). It doesn't change the cache or any API. ## Benchmark This takes 5-16% off applying the crawl on a cold start (macOS: 15.4ms -> 13.0ms, Linux: 68ms -> 64ms), and 2-3% off a cold start on Linux and Windows (Linux: 297ms -> 289ms). On macOS, cache writes are 0.4ms slower. The serialise itself takes the same time, so the difference is in the rest of the write. | | `main` | #2220 | This PR | vs `main` | vs #2220 | |---|---|---|---|---|---| | macOS: Applying the crawl in a cold start | 19.2ms | 15.4ms | 13.0ms | -32.5% (-34.5% to -30.3%) | -15.9% (-19.0% to -12.8%) | | Linux: Applying the crawl in a cold start | 83ms | 68ms | 64ms | -23.5% (-25.3% to -20.4%) | -6.5% (-8.3% to -4.1%) | | Windows: Applying the crawl in a cold start | 47ms | 34ms | 32ms | -32.4% (-33.4% to -31.5%) | -5.3% (-7.7% to -2.4%) | | macOS: Cache write in a cold start | 7.6ms | 4.4ms | 4.8ms | -36.4% (-38.9% to -33.8%) | +10.3% (+7.5% to +12.9%) | | Linux: Cache write in a cold start | 32ms | 15.0ms | 14.4ms | -55.0% (-56.4% to -52.2%) | -3.7% (-12.9% to +2.5%) | | Windows: Cache write in a cold start | 20ms | 10.6ms | 9.4ms | -53.7% (-54.6% to -52.7%) | -11.4% (-35.3% to -6.2%) | | macOS: Cold start | 146ms | 90ms | 92ms | -37.1% (-43.4% to -32.7%) | +1.7% (-9.6% to +13.9%) | | Linux: Cold start | 647ms | 297ms | 289ms | -55.3% (-55.7% to -54.9%) | -2.6% (-4.2% to -1.3%) | | Windows: Cold start | 358ms | 162ms | 158ms | -55.9% (-56.5% to -55.6%) | -2.6% (-4.4% to -1.7%) | ## Changelog ``` - **[Performance]**: metro-file-map: Skip the per-file worker pass when no plugin needs it ``` ## Test plan New unit tests. Benchmark as in #2104 (cold starts only), with 12 rounds on macOS.
With lazy SHA-1s (Metro's default), a file only needs a worker at startup if a plugin computes data for it as it's crawled. With Metro's defaults none does, since #2220 leaves out the Haste plugin without Haste config. Even so,
processBatchgoes through every crawled file to find that out, checking its path fornode_modulesand building an array of the plugins to run on it.This returns straight away when there's no SHA-1 to compute and every plugin's worker is lazy (
lazy: true, ie it computes data on demand). It doesn't change the cache or any API.Benchmark
This takes 5-16% off applying the crawl on a cold start (macOS: 15.4ms -> 13.0ms, Linux: 68ms -> 64ms), and 2-3% off a cold start on Linux and Windows (Linux: 297ms -> 289ms). On macOS, cache writes are 0.4ms slower. The serialise itself takes the same time, so the difference is in the rest of the write.
mainmainChangelog
Test plan
New unit tests. Benchmark as in #2104 (cold starts only), with 12 rounds on macOS.