forked from jj-vcs/jj
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working_copy: Only serialise clock if only clock changed
When the working copy is identical to the last snapshot - which is quite often - only the `watchman_clock` changes. When this happens, the _entirety_ of the working copy proto is reserialised, including the O(n) `file_states` field, which is slow. As non-repeated proto fields always take the last field in the serialised message ([1]), we can skip the serialisation of the whole working copy by only serialising the fields that have changed and appending it to the last serialised proto. This speeds up most `jj` commands by ~50ms on a large repository: ``` $ hyperfine --sort command --warmup 3 --runs 20 -L bin jj-before,jj-after \ "target/release/{bin} -R ~/chromiumjj/src show -s @" Benchmark 1: target/release/jj-before -R ~/chromiumjj/src show -s @ Time (mean ± σ): 401.5 ms ± 4.5 ms [User: 227.2 ms, System: 172.9 ms] Range (min … max): 394.3 ms … 414.2 ms 20 runs Benchmark 2: target/release/jj-after -R ~/chromiumjj/src show -s @ Time (mean ± σ): 347.3 ms ± 4.6 ms [User: 179.3 ms, System: 166.4 ms] Range (min … max): 340.7 ms … 358.0 ms 20 runs Relative speed comparison 1.16 ± 0.02 target/release/jj-before -R ~/chromiumjj/src show -s @ 1.00 target/release/jj-after -R ~/chromiumjj/src show -s @ ``` [1]: https://protobuf.dev/programming-guides/encoding/#last-one-wins
- Loading branch information
1 parent
31b8f07
commit ec52037
Showing
1 changed file
with
107 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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