Repository navigation
Conversation
robhogan
force-pushed
the
pr2105
branch
2 times, most recently
from
October 25, 2026 20:13
f60f8cc to
5df0bf6
Compare
Without Watchman, Metro watches with `FallbackWatcher` on Linux and Windows. Its startup walk `lstat`s every entry, files included, just to learn its type: https://github.com/react/metro/blob/56efab302200568c919ac1b3c28dacf8d84fc692/packages/metro-file-map/src/watchers/FallbackWatcher.js#L505-L515 This walks by the types `readdir` reports instead. A directory that appears while watching still needs stats for its events, so that walk now stats only the entries it reports. The walk also now descends into a watch root that's a symlink, as the crawler does. ## Benchmark This takes 40% off watch-mode startup on Linux (1,617ms -> 964ms) and 20% off on Windows. macOS uses `NativeWatcher`, so it's unaffected. | | `main` | #2104 | This PR | vs `main` | vs #2104 | |---|---|---|---|---|---| | Linux: Watch-mode start, warm cache | 1,896ms | 1,617ms | 964ms | -49.2% (-49.7% to -48.7%) | -40.4% (-40.7% to -39.7%) | | Windows: Watch-mode start, warm cache | 2,554ms | 2,429ms | 1,939ms | -24.1% (-24.7% to -23.7%) | -20.2% (-20.9% to -19.8%) | | Linux: Watch-mode start, cold cache | 1,882ms | 1,599ms | 972ms | -48.4% (-48.9% to -48.1%) | -39.2% (-39.9% to -39.0%) | | Windows: Watch-mode start, cold cache | 2,547ms | 2,419ms | 1,911ms | -25.0% (-25.3% to -24.6%) | -21.0% (-21.3% to -20.5%) | ## Changelog ``` - **[Performance]**: metro-file-map: Start the file watcher without stat-ing every file (Linux and Windows, without Watchman) ``` ## Test plan New unit test that startup doesn't `lstat` anything it finds. Benchmark as in #2104.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Without Watchman, Metro watches with
FallbackWatcheron Linux and Windows. Its startup walklstats every entry, files included, just to learn its type:metro/packages/metro-file-map/src/watchers/FallbackWatcher.js
Lines 505 to 515 in 56efab3
This walks by the types
readdirreports instead. A directory that appears while watching still needs stats for its events, so that walk now stats only the entries it reports. The walk also now descends into a watch root that's a symlink, as the crawler does.Benchmark
This takes 40% off watch-mode startup on Linux (1,617ms -> 964ms) and 20% off on Windows. macOS uses
NativeWatcher, so it's unaffected.mainmainChangelog
Test plan
New unit test that startup doesn't
lstatanything it finds. Benchmark as in #2104.