Skip to content

v1.108.83 - Tame watch-all CPU under WSL (#356)

Choose a tag to compare

@jgravelle jgravelle released this 26 Jun 18:27

Tame watch-all CPU under WSL (#356)

watch-all pegged 15-30% CPU continuously on WSL (reported by @Blainexi). Root cause is watchfiles behavior, not a busy loop: watchfiles auto-enables polling whenever it detects WSL (inotify is unreliable across the WSL boundary), and its default 300ms poll re-stats the entire watched tree several times a second, multiplied across every locally-indexed repo watch-all covers. DefaultFilter suppresses node_modules/.git events but the polling walk still stats them, so the cost is structural.

Changed

  • Poll interval floor raised 300ms to 1000ms, and made tunable. The awatch call now passes poll_delay_ms, resolved from JCODEMUNCH_WATCH_POLL_DELAY_MS (then watchfiles' own WATCHFILES_POLL_DELAY_MS), else the 1000ms default. For a background freshness daemon a ~1s cadence is invisible; the CPU drop is roughly proportional to the increase. The param is ignored entirely when native FS events are in use, so this is a no-op off WSL.
  • One-time WSL hint at watch-all startup naming the two real levers: raise JCODEMUNCH_WATCH_POLL_DELAY_MS, or for repos on the Linux filesystem set WATCHFILES_FORCE_POLLING=false to use native inotify (near-zero idle CPU). Repos under /mnt/* need polling; moving them onto the Linux filesystem is faster all round.

No INDEX_VERSION bump (runtime-only). New tests/test_v1_108_83.py (11).

PyPI: https://pypi.org/project/jcodemunch-mcp/1.108.83/