working_copy: avoid "empty" fsmonitor saves - #10049
Open
jstasiak wants to merge 1 commit into
Open
Conversation
I've been looking at jj's performance in a large (for me) repository:
Firefox.
It only became bearable with fsmonitor/watchman but I discovered that
even with no files changing advancing the fsmonitor clock triggered the
complete tree state rewrite.
I figured we could just keep the old clock if there are no changes.
Here are some "jj st" numbers from my system (macOS 26.5.2, M1 Pro,
fast NVMe, hardcoded WATCHMAN_SOCK to avoid watchman socket discovery):
jj version Runs Median ms Mean ms Min ms Max ms
stable 0.44.0 20 210.990 257.952 190.111 836.981
7190eda + this patch 20 135.723 136.843 127.764 153.652
I expect this to be safe as querying again from the older clock can
replay paths, but it cannot omit future file updates.
Stable minus custom is 75.267 ms median, 121.109 ms mean, 62.347 ms
minimum, and 683.329 ms maximum.
jstasiak
force-pushed
the
optimize-fsmonitor-empty-saves
branch
from
August 24, 2026 21:37
a4d3eb4 to
9150716
Compare
yuja
approved these changes
Aug 25, 2026
| // old clock after that scan even if it found untracked paths. | ||
| if should_update_watchman_clock | ||
| && ((stats.untracked_paths.is_empty() && stats.invalid_utf8_paths.is_empty()) | ||
| || watchman_clock.is_none()) |
Contributor
There was a problem hiding this comment.
nit: It seems slightly easier to follow nested ifs rather than combining multiple && and || conditions.
| // Reusing the older clock may make a later query do more work, but it | ||
| // cannot omit changes. | ||
| let should_update_watchman_clock = | ||
| !matches!(&changed_files, Some(files) if files.is_empty()); |
Contributor
There was a problem hiding this comment.
nit: .as_ref().is_some_and() or .is_none_or() also works.
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.
I've been looking at jj's performance in a large (for me) repository: Firefox.
It only became bearable with fsmonitor/watchman but I discovered that even with no files changing advancing the fsmonitor clock triggered the complete tree state rewrite.
I figured we could just keep the old clock if there are no changes.
Here are some "jj st" numbers from my system (macOS 26.5.2, M1 Pro,
fast NVMe, hardcoded WATCHMAN_SOCK to avoid watchman socket discovery):
I expect this to be safe as querying again from the older clock can replay paths, but it cannot omit future file updates.
Stable minus custom is 75.267 ms median, 121.109 ms mean, 62.347 ms minimum, and 683.329 ms maximum.
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.