Skip to content

Support @parcel/watcher as the watcher alternative#13699

Merged
nachocodoner merged 18 commits intorelease-3.3from
parcel-watcher-support
Apr 23, 2025
Merged

Support @parcel/watcher as the watcher alternative#13699
nachocodoner merged 18 commits intorelease-3.3from
parcel-watcher-support

Conversation

@nachocodoner
Copy link
Copy Markdown
Member

@nachocodoner nachocodoner commented Apr 16, 2025

Continues: #13657 and #13698

This PR continues the optimizations after switching to the SWC transpiler and dropping legacy compilation. It focuses on refactoring the file watchers used by Meteor, replacing them with a modern, native, and cross-platform tool: @parcel/watcher.

The change was suggested by @zodern. After reviewing the involved code, I found that Meteor used two libraries: Pathwatcher on Linux and vscode-NSFW on Windows/macOS. On Windows and macOS, Meteor enabled a single recursive watcher per directory using vscode-nsfw, efficiently covering whole trees. On Linux, recursive watchers weren’t available, and adding one per subdirectory would overload the system. To avoid that, Meteor used `pathwatcher, watching files and some directories individually. This added up to 5 seconds of delay in Linux when reacting to file changes, especially for new files.

The @parcel/watcher library offers a modern solution for recursive watching across platforms. It uses native backends: FSEvents (macOS), inotify or Watchman (Linux), and the Windows API. All through a unified interface. It supports recursive watching on all platforms, which is the key improvement here.

Results can be seen using METEOR_MONITOR_PROCESS=true in meteor profile. This outputs the full profile process. The “Meteor(Total)” time shows only what the internal profiler sees, not including watcher reaction time. The new “Meteor(Progress)” output includes delays like startup wait and file change reactions. This metric helps confirm the improvements in this PR. See the next profiles for reference:

image

The results got from a specific machine using fredmaiaarantes/simpletasks in a Linux-like OS

It seems to have improved the prepareProjectForBuild phase, likely because it involves setting up file watching. There's also a slight improvement in build and rebuild times. In some profiles, the safeWatcher.watch process appears as well.

This still needs more testing across all OS, but results so far look good.


  • Investigate why ./meteor --get-ready fails; possible memory leak or limit with @parcel/watcher?
    • Apps tested locally worked well without issues.
  • Ensure to mark a path as being subscribed beforehand to avoid parallel repeated subscriptions to the same folder context
    • Any gain out of this change?
  • Remove LRU on file replacement since finally was not needed to fix an issue
  • Fix tests affected by file watcher replacement

…oss-os perserving polling fallback""

This reverts commit 6de4d9d.
Base automatically changed from exclude-legacy-often to release-3.3 April 22, 2025 20:52
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 23, 2025

Deploy Preview for v3-meteor-api-docs canceled.

Name Link
🔨 Latest commit c2dcae2
🔍 Latest deploy log https://app.netlify.com/sites/v3-meteor-api-docs/deploys/6808c496e9593e0008d26e34

@nachocodoner nachocodoner added this to the Release 3.3 milestone Apr 23, 2025
@nachocodoner nachocodoner marked this pull request as ready for review April 23, 2025 11:29
@nachocodoner
Copy link
Copy Markdown
Member Author

Finally! This branch is ready to merge into 3.3. Next, I’ll test it more thoroughly across OS with all other changes in place.

@nachocodoner nachocodoner merged commit 518a04c into release-3.3 Apr 23, 2025
10 checks passed
@nachocodoner nachocodoner deleted the parcel-watcher-support branch April 23, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants