What problem does this solve?
The watcher currently hard-caps per-project poll intervals at 60s (POLL_MAX_MS = 60000 in src/watcher/watcher.c). Each poll fires two supervised git subprocesses per watched repo (git rev-parse HEAD + git status --porcelain -uall -z). On Windows with many large repos under CBM_ALLOWED_ROOT, this creates continuous background CPU/IO load that is too aggressive for developer workstations.
Environment / scale
| Metric |
Value |
| Indexed projects |
244 |
| Total graph nodes |
~4.4M |
| Total graph edges |
~18M |
| Total cache size |
~15 GB |
| Projects > 100k nodes |
9 |
| Largest project (nodes) |
~475k |
| OS |
Windows 11 |
At the 60s max poll interval, the watcher fires git rev-parse HEAD + git status --porcelain -uall -z per git-detected project every minute. On Windows, git status -uall on large repos is particularly expensive (no fsmonitor equivalent by default), and with this many projects the load is continuous.
Proposed solution
Add a CBM_WATCH_MAX_INTERVAL_MS environment variable that overrides POLL_MAX_MS in cbm_watcher_poll_interval_ms(), following the existing pattern of CBM_WATCHER_PRUNE_GRACE_S. This would allow users to set the cap to e.g. 1 hour (3600000) without disabling watching entirely.
Suggested implementation
int cbm_watcher_poll_interval_ms(int file_count) {
const char *raw = getenv("CBM_WATCH_MAX_INTERVAL_MS");
int max_ms = POLL_MAX_MS;
if (raw && raw[0]) {
long v = strtol(raw, NULL, 10);
if (v > 0) {
max_ms = (v > INT_MAX) ? INT_MAX : (int)v;
}
}
int ms = POLL_BASE_MS + ((file_count / POLL_FILE_STEP) * CBM_MSEC_PER_SEC);
return ms > max_ms ? max_ms : ms;
}
Environment
- OS: Windows 11
- CBM_ALLOWED_ROOT: large directory tree with many git repos
- CBM_WORKERS=2, CBM_MEM_BUDGET_MB=4096
Alternatives considered
No response
Confirmations
What problem does this solve?
The watcher currently hard-caps per-project poll intervals at 60s (POLL_MAX_MS = 60000 in src/watcher/watcher.c). Each poll fires two supervised git subprocesses per watched repo (git rev-parse HEAD + git status --porcelain -uall -z). On Windows with many large repos under CBM_ALLOWED_ROOT, this creates continuous background CPU/IO load that is too aggressive for developer workstations.
Environment / scale
At the 60s max poll interval, the watcher fires git rev-parse HEAD + git status --porcelain -uall -z per git-detected project every minute. On Windows, git status -uall on large repos is particularly expensive (no fsmonitor equivalent by default), and with this many projects the load is continuous.
Proposed solution
Add a CBM_WATCH_MAX_INTERVAL_MS environment variable that overrides POLL_MAX_MS in cbm_watcher_poll_interval_ms(), following the existing pattern of CBM_WATCHER_PRUNE_GRACE_S. This would allow users to set the cap to e.g. 1 hour (3600000) without disabling watching entirely.
Suggested implementation
int cbm_watcher_poll_interval_ms(int file_count) {
const char *raw = getenv("CBM_WATCH_MAX_INTERVAL_MS");
int max_ms = POLL_MAX_MS;
if (raw && raw[0]) {
long v = strtol(raw, NULL, 10);
if (v > 0) {
max_ms = (v > INT_MAX) ? INT_MAX : (int)v;
}
}
int ms = POLL_BASE_MS + ((file_count / POLL_FILE_STEP) * CBM_MSEC_PER_SEC);
return ms > max_ms ? max_ms : ms;
}
Environment
Alternatives considered
No response
Confirmations