Severe CPU usage caused by repeated file-watcher re-registration
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
I encountered a severe CPU issue with Pyrefly 1.1.1 in VS Code 1.129.0 on macOS 26.5.2 (M1
Pro, 16 GB RAM).
In a workspace containing over 20,000 files, including approximately 10,000 Python files,
the VS Code extension host continuously consumed 155–230% CPU. The system load average
reached 30–41, causing the machine to become extremely hot.
Process sampling showed repeated uv_fs_poll and uv_fs_stat activity. The Pyrefly log
continuously repeated this sequence:
DidChangeWatchedFiles
Re-registering file watchers
Invalidated state, prepare to recheck open files
The log grew by approximately 6.7 KB in 12 seconds, with 24 watcher re-registration cycles
in the last 240 lines.
After disabling Pyrefly:
- The Pyrefly process exited and its log stopped growing.
- VS Code extension-host CPU dropped to 4.6–6.6%.
- CPU idle time increased to approximately 70%.
- The one-minute load average dropped from 41 to 11 and continued decreasing.
This strongly suggests a feedback loop involving DidChangeWatchedFiles and file-watcher re-
registration. Please investigate this behavior. I can provide the full logs and process
sample if needed.
### Sandbox Link
_No response_
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Research direction
Reproduce the issue in a VS Code workspace with more than 20,000 files and inspect the Pyrefly log for repeated DidChangeWatchedFiles and watcher re-registration cycles. Trace the file-watcher handling from those log events; done means re-registration no longer loops and CPU usage remains low in the large workspace.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust, vscode
- Domain
- devtools, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100