Skip to content

watchman: cache the socket path - #10093

Open
jstasiak wants to merge 1 commit into
jj-vcs:mainfrom
jstasiak:optimize-watchman-socket
Open

watchman: cache the socket path#10093
jstasiak wants to merge 1 commit into
jj-vcs:mainfrom
jstasiak:optimize-watchman-socket

Conversation

@jstasiak

@jstasiak jstasiak commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes
  • I fully understand the code that I am submitting (what it does,
    how it works, how it's organized), including any code drafted by an LLM.
  • For any prose generated by an LLM, I have proof-read and copy-edited with
    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.

@jstasiak
jstasiak requested a review from a team as a code owner August 31, 2026 23:04
@jstasiak jstasiak changed the title watchman: cache the socket watchman: cache the socket path Aug 31, 2026
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
jstasiak force-pushed the optimize-watchman-socket branch from d5cb0e8 to c7940ee Compare August 31, 2026 23:05
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