mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-30 16:10:23 +00:00
bb94516175
We currently need to read the commit objects for finding common ancestors. That can be very slow when the common ancestor is far back in history. This patch adds a function for finding common ancestors using the index instead. Unlike the current algorithm, which only returns one common ancestor, the new index-based one correctly handles criss-cross merges. Here are some timings for finding the common ancestors in the git.git repo: | Without index | With Index | | First run | Subsequent | First run | Subsequent | v2.30.0-rc0 v2.30.0-rc1 | 5.68 ms | 5.94 us | 40.3 us | 4.77 us | v2.25.4 v2.26.1 | 1.75 ms | 1.42 us | 13.8 ms | 4.29 ms | v1.0.0 v2.0.0 | 492 ms | 2.79 ms | 23.4 ms | 6.41 ms | Finding ancestors of v2.25.4 and v2.26.1 got much slower because the new algorithm finds all common ancestors. Therefore, it also finds v2.24.2, v2.23.2, v2.22.3, v2.21.2, v2.20.3, v2.19.4, v2.18.3, and v2.17.4, which it then filters out because they're all ancestors of v2.25.3. Also note that the result was incorrect before, because the old algorithm would return as soon as it had found a common ancestor, even if it's not the latest common ancestor. For example, for the common ancestor between v1.0.0 and v2.0.0, it returned an ancestor of v1.0.0 because it happened to get there by following some side branch that led there more quickly. The only place we currently need to find the common ancestor is when merging trees, which we only do when the user runs `jj merge`, as well as when operating on existing merge commits (e.g. to diff or rebase them). That means that this change won't be very noticeable. However, it's something we clearly want to do sooner or later, so we might as well get it done. |
||
---|---|---|
.. | ||
protos | ||
src | ||
tests | ||
build.rs | ||
Cargo.toml |