Skip to content

perf: make repository monitoring non-interfering - #8

Merged
fieldsofland merged 1 commit into
mainfrom
codex/stackmap-monitoring-fix
Jul 21, 2026
Merged

perf: make repository monitoring non-interfering#8
fieldsofland merged 1 commit into
mainfrom
codex/stackmap-monitoring-fix

Conversation

@fieldsofland

Copy link
Copy Markdown
Owner

Summary

Stackmap can now monitor large repositories without competing with normal Git commands or consuming a CPU core while idle. Passive inventory work cannot acquire the Git index lock, repository notifications collapse into one refresh after activity settles, and recoverable exits leave no monitoring workers or child processes behind.

Design

  • Run passive Git commands with GIT_OPTIONAL_LOCKS=0, while preserving normal locking and a separate 30-second deadline for explicit checkout and deletion mutations.
  • Filter .git notifications to state that affects the branch map, ignore transient locks and object-store churn, and debounce relevant bursts for 200 ms.
  • Use five-minute reconciliation only as a dropped-event safety net instead of repeatedly scanning every 30 seconds.
  • Supervise subprocess groups and join watcher, refresh, and upstream workers during normal quit, Ctrl-C, SIGHUP, SIGTERM, and recoverable error exits.
  • Give timed-out commands a graceful TERM window before forced termination.

Measurements

FactMachine monorepo Before After
Settled CPU per runaway instance 88–98% 0.0%
Passive monitoring can create index.lock Yes No
Process remains after q Observed None
Fallback reconciliation 30 seconds 5 minutes

Checkout and guarded deletion retain their existing mutation semantics and integration coverage.

Verification

  • cargo fmt --check
  • cargo clippy --offline --all-targets --all-features -- -D warnings
  • cargo test --offline --all-targets --all-features (176 tests)
  • Offline release build
  • Live startup, idle CPU, index-lock, and shutdown smoke test in the FactMachine monorepo

Compound Engineering
Codex

Use lock-free passive Git reads and debounced filesystem events to eliminate index contention and refresh storms. Supervise child processes and join monitoring workers so normal shutdown leaves no orphaned repository work.
@fieldsofland
fieldsofland merged commit 9b624e9 into main Jul 21, 2026
4 checks passed
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.

1 participant