Repository navigation
Conversation
On Windows, `FallbackWatcher` waits a second after setting up its watches: https://github.com/react/metro/blob/56efab302200568c919ac1b3c28dacf8d84fc692/packages/metro-file-map/src/watchers/FallbackWatcher.js#L77-L82 That's a holdover from `sane`. libuv issues `ReadDirectoryChangesW` before `uv_fs_event_start` returns, so a watch is live as soon as `fs.watch` returns: https://github.com/libuv/libuv/blob/840404ce8ba7cc0204be52389a6cfff9f2c90fb6/src/win/fs-event.c#L310-L326 ## Benchmark This takes 52% off watch-mode startup on Windows (1,939ms -> 926ms), about the second you'd expect. Linux is unchanged. | | `main` | #2105 | This PR | vs `main` | vs #2105 | |---|---|---|---|---|---| | Linux: Watch-mode start, warm cache | 1,896ms | 964ms | 969ms | -48.9% (-49.4% to -48.5%) | +0.5% (-0.1% to +1.0%) | | Windows: Watch-mode start, warm cache | 2,554ms | 1,939ms | 926ms | -63.7% (-63.9% to -63.6%) | -52.2% (-52.5% to -51.9%) | | Linux: Watch-mode start, cold cache | 1,882ms | 972ms | 967ms | -48.6% (-49.2% to -47.8%) | -0.5% (-1.0% to +1.1%) | | Windows: Watch-mode start, cold cache | 2,547ms | 1,911ms | 912ms | -64.2% (-64.3% to -64.0%) | -52.3% (-52.5% to -52.1%) | ## Changelog ``` - **[Performance]**: metro-file-map: Remove a 1s delay from file watcher startup on Windows without Watchman ``` ## Test plan New unit test that changes made as soon as `startWatching` resolves are reported. It runs on Linux and Windows, and is skipped on macOS, where `fs.watch` starts FSEvents asynchronously (but `FallbackWatcher` isn't used). 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.
On Windows,
FallbackWatcherwaits a second after setting up its watches:metro/packages/metro-file-map/src/watchers/FallbackWatcher.js
Lines 77 to 82 in 56efab3
That's a holdover from
sane. libuv issuesReadDirectoryChangesWbeforeuv_fs_event_startreturns, so a watch is live as soon asfs.watchreturns:https://github.com/libuv/libuv/blob/840404ce8ba7cc0204be52389a6cfff9f2c90fb6/src/win/fs-event.c#L310-L326
Benchmark
This takes 52% off watch-mode startup on Windows (1,939ms -> 926ms), about the second you'd expect. Linux is unchanged.
mainmainChangelog
Test plan
New unit test that changes made as soon as
startWatchingresolves are reported. It runs on Linux and Windows, and is skipped on macOS, wherefs.watchstarts FSEvents asynchronously (butFallbackWatcherisn't used). Benchmark as in #2104.