Skip to content

fix: daemon resource thresholds incompatible with macOS#1078

Open
ezhilvendhan wants to merge 1 commit intoruvnet:mainfrom
ezhilvendhan:fix/daemon-resource-thresholds-macos
Open

fix: daemon resource thresholds incompatible with macOS#1078
ezhilvendhan wants to merge 1 commit intoruvnet:mainfrom
ezhilvendhan:fix/daemon-resource-thresholds-macos

Conversation

@ezhilvendhan
Copy link

Summary

Fixes #1077 — Daemon workers never execute on macOS due to unrealistic resource thresholds in canRunWorker().

Three issues fixed:

  1. maxCpuLoad: 2.0 too low for multi-core systemsos.loadavg() returns system-wide load (not per-core). An 8-core Mac under normal workload reports ~8-16, far exceeding 2.0. Changed to dynamic core-aware threshold (os.cpus().length * 3).

  2. minFreeMemoryPercent: 20 incompatible with macOSos.freemem() on macOS only reports truly unused RAM, excluding reclaimable cached/purgeable memory. A typical Mac shows 1-5% "free" even with plenty available. Changed default to 1%.

  3. --quiet flag hardcoded in background daemon spawndaemon.ts line 217 hardcoded --quiet, suppressing all worker event logging to the daemon log file, making diagnosis impossible.

Changes

  • worker-daemon.ts: Changed maxCpuLoad default from 2.0 to 0 (signals dynamic threshold). Updated canRunWorker() to compute core-aware threshold when config is 0.
  • worker-daemon.ts: Changed minFreeMemoryPercent default from 20 to 1.
  • daemon.ts: Removed hardcoded --quiet flag from background process spawn.

Test plan

  • Verified map worker executes immediately on macOS (was permanently deferred before)
  • Verified audit worker starts after 120s offset
  • Verified codebase-map.json metrics file is written
  • Verified daemon state file updates with runCount > 0
  • Test on Linux to confirm behavior unchanged (load avg reporting is similar)

Context

The combination of low thresholds + the deadlock in processPendingWorkers() (addressed separately in #1052) means zero workers ever execute on macOS. This PR fixes the root cause while #1052 fixes the amplification.

The daemon canRunWorker() resource check has two threshold defaults that
prevent workers from ever executing on macOS:

1. maxCpuLoad: 2.0 — os.loadavg() returns system-wide load (not per-core),
   so an 8-core Mac under normal workload reports ~8-16, far exceeding 2.0.
   Changed to 0 (dynamic) with core-aware threshold of cpus().length * 3.

2. minFreeMemoryPercent: 20 — macOS os.freemem() only reports truly unused
   RAM (not reclaimable cache), typically showing 1-5% on a Mac even with
   plenty available. Changed to 1%.

Also removed hardcoded --quiet flag from background daemon spawn that
suppressed all worker event logging to the log file.

Fixes ruvnet#1077
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Daemon workers never execute on macOS due to unrealistic resource thresholds

1 participant