watchman: cache the socket path - #10093
Open
jstasiak wants to merge 1 commit into
Open
Conversation
When no socket is provided watchman_client runs full Watchman CLI
solely to discover it and running Watchman is slow-ish (to the point
where it can dominate the cost of short jj commands), at least in the
environment I tested (macOS 26.5.2, M1 Pro).
50 runs test (small repo to make the difference more obvious, the actual
watchman get-sockname command to demonstrate the point):
Command Mean ms Min ms Median ms Max ms
======================== ======= ======= ========= =======
watchman get-sockname 133.173 129.363 132.186 161.242
jj status (0.44.0) 166.157 161.038 165.656 187.851
jj status (this patch) 36.437 32.206 34.483 96.386
Remember the last endpoint in the platform cache directory and validate
it with a cheap protocol request before use. Fall back to normal CLI
discovery and refresh atomically when it is stale. Explicit nonempty
WATCHMAN_SOCK values retain their existing behavior and do not affect
the cache.
serde_bser is not actually a new dependency, watchman_client already
pulls it in.
jstasiak
force-pushed
the
optimize-watchman-socket
branch
from
August 31, 2026 23:05
d5cb0e8 to
c7940ee
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.
When no socket is provided watchman_client runs full Watchman CLI solely to discover it and running Watchman is slow-ish (to the point where it can dominate the cost of short jj commands), at least in the environment I tested (macOS 26.5.2, M1 Pro).
50 runs test (small repo to make the difference more obvious, the actual watchman get-sockname command to demonstrate the point):
Remember the last endpoint in the platform cache directory and validate it with a cheap protocol request before use. Fall back to normal CLI discovery and refresh atomically when it is stale. Explicit nonempty WATCHMAN_SOCK values retain their existing behavior and do not affect the cache.
serde_bser is not actually a new dependency, watchman_client already pulls it in.
Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)how it works, how it's organized), including any code drafted by an LLM.
an eye towards deleting anything that is irrelevant, clarifying anything
that is confusing, and adding details that are relevant. This includes,
for example, commit descriptions, PR descriptions, and code comments.