Batch macOS process discovery - #348
Open
sdairs wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves local ClickHouse server discovery performance on macOS by resolving all candidate process working directories in a single lsof invocation, while preserving the Linux /proc/<pid>/cwd fast path. It also adds focused unit coverage for parsing batched lsof -Fn output so discovery remains robust when some PIDs disappear during inspection.
Changes:
- Batch macOS cwd discovery into one
lsof -a -d cwd -Fn -p <pid1,pid2,...>call and parse per-PID records (p<pid>/n<path>). - Adjust discovery flow to precompute a PID→cwd map and pass cwd into
inspect_process(instead of resolving per-PID inline). - Add parser tests for correct attribution and malformed/incomplete record handling.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sdairs
force-pushed
the
codex/issue-329-batch-lsof
branch
from
August 3, 2026 18:42
22ff6b8 to
75937bb
Compare
sdairs
marked this pull request as ready for review
August 3, 2026 19:34
sdairs
force-pushed
the
codex/issue-329-batch-lsof
branch
from
August 3, 2026 19:34
75937bb to
577468d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lsofcall on macOSlsof -FnPID/path records and retain valid records if another process exits during discovery/proc/<pid>/cwdfast path and add focused parser coverageWhy
Process discovery previously launched one
lsofsubprocess per process namedclickhouse. On agent-heavy machines with many clickhouse-local or chDB processes, that made local commands stall for tens of seconds even when none of those processes belonged to the current project.Impact
macOS discovery now pays the
lsofstartup cost once regardless of the number of ClickHouse processes. The CLI surface and Linux behavior are unchanged.Stack
This PR is stacked on #347 and should be reviewed as the delta from
codex/issue-337-org-autodetect.Closes #329.
Validation
cargo fmt --all --checkcargo build -p clickhousectl --all-targetscargo test -p clickhousectl(570 tests)cargo clippy -p clickhousectl --all-targets -- -D warningslsof -Fnoutput on macOS