git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/7] Optimization batch 11: avoid repeatedly detecting same renames

From
Elijah Newren <newren@gmail.com>
Date
Mar 29, 2021, 22:34 UTC
Message-ID
<CABPp-BGrevGj+xrm9bVcX5bp_WRv9cYP+g0hrAtjZK0u=sTHzQ@mail.gmail.com>
In-Reply-To
<xmqqzgyrukic.fsf@gitster.g>
On Thu, Mar 25, 2021 at 12:00 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 35 quoted lines
>
> Elijah Newren <newren@gmail.com> writes:
>
> >> And each step in this "rebase" is a 3-way merge of commits A, B and
> >> C onto HEAD, using the parent of the commit being cherrk-picked as a
> >> virtual common ancestor.  Which means
> >
> > You generated nearly the same description and diagram I used in the
> > commit message (the one in 3/7) describing this.  :-)
> >
> >>  - To transplant A (i.e. the first step), we'd compare the diff of
> >>    A^..O (i.e. what our side did, including the renames done at X)
> >>    and diff of A^..A (i.e. what the first commit did in the range),
> >>    and the former does quite a lot of rename detection.
> >>
> >>  - After transplanting B (i.e. the second step), then we'd compare
> >>    the diff of A^..A' (where A' is A cherry-picked on O, i.e. the
> >
> > Close, but for transplanting B we do the diff of B^..A', not A^...A'.
> > (And in this diagram, B^ is A.)  That's critical below...
>
> Yes, I upfront said "pretend that the parent of the commit being
> picked is the common ancestor and run 3-way merge", but then got
> confused by the ancestry graph myself, forgetting that the reason
> why A^ is used in the first "pick" is *not* because the it is the
> fork point of our history and the side branch, but it is because it
> is A's parent.
>
> And if the renames in B^..A' and A^..A' are different that must have
> come only from the difference between A..B (which is B^..B), but
> that comparison is what we do when cherry-picking B on top of A',
> so it is easy to take into account to reuse the renames precisely
> without "assuming they are the same".
>
> Thanks.
After sending the initial series, I decided to type up a more thorough
document that
  * spelled out in more detail how the sequence of cherry-picks work
  * proved why the renames in one pick are always a superset of the
renames in the next
  * proved why the renames in one pick are _almost_ always also a
rename in the next
  * discussed the counterexample cases in more detail, and why the
optimization is still reasonable
I figured the more extended document would be useful in case people
decide to change how things work in the future (e.g. what if someone
wants to turn on break detection?), and wants to be able to check
whether all the conditions and cases still hold.

I then also added details about how things work with directory renames, in the case that merge.directoryRenames is not the default of "conflict" (which is trivially handled by stopping and dropping the cache) but is set to true...and found a case that needed more care due to interactions with some of the earlier optimizations. (The earlier optimizations could result in bypassing directory rename detection in one merge because there was no file added to the old directory, but the no-directory-rename would be cached for subsequent rebases.)

So I need to get that fixed up and resubmit this series.
Previous: Junio C HamanoNext: Derrick Stolee
Message 12 of 61 in “Optimization batch 11: avoid repeatedly detecting same renames”
  1. 0/7 Optimization batch 11: avoid repeatedly detecting same renamesElijah Newren via GitGitGadget, Mar 24, 2021
  2. 2/7 merge-ort: populate caches of rename detection resultsElijah Newren via GitGitGadget, Mar 24, 2021
  3. 1/7 merge-ort: add data structures for in-memory caching of rename detectionElijah Newren via GitGitGadget, Mar 24, 2021
  4. 4/7 merge-ort: avoid accidental API mis-useElijah Newren via GitGitGadget, Mar 24, 2021
  5. 3/7 merge-ort: add code to check for whether cached renames can be reusedElijah Newren via GitGitGadget, Mar 24, 2021
  6. 5/7 merge-ort: preserve cached renames for the appropriate sideElijah Newren via GitGitGadget, Mar 24, 2021
  7. 6/7 merge-ort: add helper functions for using cached renamesElijah Newren via GitGitGadget, Mar 24, 2021
  8. 7/7 merge-ort, diffcore-rename: employ cached renames when possibleElijah Newren via GitGitGadget, Mar 24, 2021
  9. Junio C HamanoMar 24, 2021
  10. Elijah NewrenMar 24, 2021
  11. Junio C HamanoMar 25, 2021
  12. Elijah NewrenMar 29, 2021
  13. Derrick StoleeMar 30, 2021
  14. 00/13 Optimization batch 11: avoid repeatedly detecting same renamesElijah Newren via GitGitGadget, May 4, 2021
  15. 01/13 t6423: rename file within directory that other side renamedElijah Newren via GitGitGadget, May 4, 2021
  16. 03/13 fast-rebase: change assert() to BUG()Elijah Newren via GitGitGadget, May 4, 2021
  17. 04/13 fast-rebase: write conflict state to working tree, index, and HEADElijah Newren via GitGitGadget, May 4, 2021
  18. Derrick StoleeMay 17, 2021
  19. Elijah NewrenMay 18, 2021
  20. Derrick StoleeMay 18, 2021
  21. 02/13 Documentation/technical: describe remembering renames optimizationElijah Newren via GitGitGadget, May 4, 2021
  22. 07/13 merge-ort: populate caches of rename detection resultsElijah Newren via GitGitGadget, May 4, 2021
  23. Derrick StoleeMay 17, 2021
  24. Elijah NewrenMay 20, 2021
  25. 06/13 merge-ort: add data structures for in-memory caching of rename detectionElijah Newren via GitGitGadget, May 4, 2021
  26. Derrick StoleeMay 17, 2021
  27. Elijah NewrenMay 18, 2021
  28. Derrick StoleeMay 18, 2021
  29. 05/13 t6429: testcases for remembering renamesElijah Newren via GitGitGadget, May 4, 2021
  30. 08/13 merge-ort: add code to check for whether cached renames can be reusedElijah Newren via GitGitGadget, May 4, 2021
  31. Derrick StoleeMay 17, 2021
  32. 10/13 merge-ort: preserve cached renames for the appropriate sideElijah Newren via GitGitGadget, May 4, 2021
  33. 11/13 merge-ort: add helper functions for using cached renamesElijah Newren via GitGitGadget, May 4, 2021
  34. 12/13 merge-ort: handle interactions of caching and rename/rename(1to1) casesElijah Newren via GitGitGadget, May 4, 2021
  35. Derrick StoleeMay 17, 2021
  36. 13/13 merge-ort, diffcore-rename: employ cached renames when possibleElijah Newren via GitGitGadget, May 4, 2021
  37. Derrick StoleeMay 17, 2021
  38. Elijah NewrenMay 20, 2021
  39. Derrick StoleeMay 22, 2021
  40. 09/13 merge-ort: avoid accidental API mis-useElijah Newren via GitGitGadget, May 4, 2021
  41. Derrick StoleeMay 17, 2021
  42. Elijah NewrenMay 14, 2021
  43. Derrick StoleeMay 14, 2021
  44. 00/13 Optimization batch 11: avoid repeatedly detecting same renamesElijah Newren via GitGitGadget, May 20, 2021
  45. 01/13 t6423: rename file within directory that other side renamedElijah Newren via GitGitGadget, May 20, 2021
  46. 02/13 Documentation/technical: describe remembering renames optimizationElijah Newren via GitGitGadget, May 20, 2021
  47. Bagas SanjayaMay 20, 2021
  48. Kerry, RichardMay 20, 2021
  49. Elijah NewrenMay 20, 2021
  50. 03/13 fast-rebase: change assert() to BUG()Elijah Newren via GitGitGadget, May 20, 2021
  51. 04/13 fast-rebase: write conflict state to working tree, index, and HEADElijah Newren via GitGitGadget, May 20, 2021
  52. 05/13 t6429: testcases for remembering renamesElijah Newren via GitGitGadget, May 20, 2021
  53. 08/13 merge-ort: add code to check for whether cached renames can be reusedElijah Newren via GitGitGadget, May 20, 2021
  54. 07/13 merge-ort: populate caches of rename detection resultsElijah Newren via GitGitGadget, May 20, 2021
  55. 06/13 merge-ort: add data structures for in-memory caching of rename detectionElijah Newren via GitGitGadget, May 20, 2021
  56. 09/13 merge-ort: avoid accidental API mis-useElijah Newren via GitGitGadget, May 20, 2021
  57. 10/13 merge-ort: preserve cached renames for the appropriate sideElijah Newren via GitGitGadget, May 20, 2021
  58. 12/13 merge-ort: handle interactions of caching and rename/rename(1to1) casesElijah Newren via GitGitGadget, May 20, 2021
  59. 11/13 merge-ort: add helper functions for using cached renamesElijah Newren via GitGitGadget, May 20, 2021
  60. 13/13 merge-ort, diffcore-rename: employ cached renames when possibleElijah Newren via GitGitGadget, May 20, 2021
  61. Derrick StoleeMay 22, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.