land: perf-spawn-without-fork

AF
3h ago
+704-15

Accepted agent delivery; branch-keyed search descriptor included.


Summary by cubic

Stops formatter, checker, and git spawns in the daemon from forking the process: they now spawn through posix_spawn, and the per-edit git root-commit probe is reused until the repository's git files change. Forking the large multi-threaded daemon took every malloc lock and stalled allocation process-wide on macOS.

Details

  • isolate_in_process_group sets process_group(0) instead of a pre_exec setsid, keeping child spawns on the posix_spawn path; timeout kills still reach grandchildren through the process group, and unreaped zombies count as exited, not alive.
  • A bare program name whose effective PATH differs from the process PATH is resolved against that PATH in the parent and spawned by absolute path with the same argv[0] and child environment; relative or empty PATH entries keep the child-side lookup.
  • Root-commit results are cached keyed on HEAD and the git files that decide it; the cache holds only when a stamp re-captured after probing matches. Nothing is cached for git env overrides, reftable, symlink identities, or non-branch HEADs.
  • Background bash keeps its fork path.

RetriggerView in GreptileConfidence Score: 3/5

Fix the tool-search fallback and stale root keys before merging.

Findings

  1. P1 Working tools are skipped ▶
  2. P1 History changes keep old keys ▶

Summary

The PR reduces daemon forks and reuses Git root probes.

  • Formatters and Git helpers avoid fork-based launches.
  • Repeated lookups reuse a Git root-commit result while repository history stays unchanged.

Reviews (3) · Last reviewed commit: "mason: validate root-commit cache stamps..." · Reviewed by Greptile