Repository navigation
Commit 7f79b7a
committed
metro-file-map: Skip the per-file worker pass when no plugin needs it
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.1 parent c489a4b commit 7f79b7a
2 files changed
Lines changed: 53 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| |||
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
90 | 95 | | |
91 | 96 | | |
92 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
93 | 109 | | |
94 | 110 | | |
95 | 111 | | |
| |||
110 | 126 | | |
111 | 127 | | |
112 | 128 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | 129 | | |
120 | 130 | | |
121 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
279 | 316 | | |
280 | 317 | | |
281 | 318 | | |
| |||
0 commit comments