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

Re: [PATCH v3 3/9] diffcore-rename: simplify limit check

From
Elijah Newren <newren@gmail.com>
Date
Nov 10, 2021, 20:06 UTC
Message-ID
<CABPp-BFqZj4qYXbPGLyX=4RM4OdLNL=VbYyhbLakU-RrvU+wfw@mail.gmail.com>
In-Reply-To
<CAPNYHkm5Qp8HQGU5_6DXc7xpCrdGgEin0WYAxbRNOkKW0j2ERQ@mail.gmail.com>
On Tue, Nov 9, 2021 at 1:15 PM Başar Uğur <basarugur@gmail.com> wrote:
Show 9 quoted lines
>
> Hi all,
>
> First post on Git mailing list, to provide a comment on a patch. Hope
> this works.
>
> In cases where the `rename_limit` is already greater than 65535, the
> `st_mult(rename_limit, rename_limit)` multiplication overflows and
> process halts.

Out of curiosity, what system are you on? And how many renames do you actually have?

We used to clamp to 32767, but one specific repository needed values larger than that, in the range of ~50000. However, due to a number of rename detection related optimizations added since then, the git of today can handle that same particular repository and support full rename detection with a rename limit under 1000 for merge/cherry-pick (sorry, forgot the exact numbers), and probably less than 10000 for diff (just guestimating; I don't want to go and check).

Anyway, all that aside, I don't see any such overflow for rename_limit being 2**16; we can push it much farther:

    size_t a = 4294967295;   /*  2**32 -1  */
    size_t b = a;
    size_t c = st_mult(a, b);
    printf("%"PRIuMAX" = %"PRIuMAX" * %"PRIuMAX"\n", c, a, b);
Output:
    18446744065119617025 = 4294967295 * 4294967295
Adding one to the value of a results in:
    fatal: size_t overflow: 4294967296 * 4294967296
Show 5 quoted lines
> But I don't think an 'overflow error' is very helpful
> for the users in understanding what is wrong with their configuration;
> i.e. `diff.renameLimit` documentation says nothing about a 'maximum
> allowed value'. I would either clamp it to a reasonable range, or
> inform the users about the limits, or maybe both.

That sounds reasonable, but I'm not sure it's worth the effort in practice. 2**32 - 1 is so impractically large for a rename_limit that I don't see why anyone would need a value even remotely close to that level (and I wouldn't at all be surprised if other things in git scaling broke before we even got to that point).

Perhaps you're dealing with a 32-bit system? Even then, the repository that hit this was about 6.5GB packed .git history; and you might need to be a lot larger than that given the optimization since then in order to hit this. Can 32-bit systems even handle that size of repository without dying in several other ways?

Previous: Başar UğurNext: Başar Uğur
Message 49 of 55 in “diffcore-rename improvements”
  1. 0/7 diffcore-rename improvementsElijah Newren via GitGitGadget, Dec 6, 2020
  2. 4/7 diffcore-rename: change a few comments to use 'add' instead of 'create'Elijah Newren via GitGitGadget, Dec 6, 2020
  3. Junio C HamanoDec 10, 2020
  4. 2/7 diffcore-rename: remove unnecessary if-clauseElijah Newren via GitGitGadget, Dec 6, 2020
  5. Taylor BlauDec 9, 2020
  6. Elijah NewrenDec 10, 2020
  7. Junio C HamanoDec 10, 2020
  8. Elijah NewrenDec 10, 2020
  9. Junio C HamanoDec 10, 2020
  10. Elijah NewrenDec 6, 2020
  11. 7/7 Accelerate rename_dst setupElijah Newren via GitGitGadget, Dec 6, 2020
  12. Taylor BlauDec 9, 2020
  13. Elijah NewrenDec 10, 2020
  14. Junio C HamanoDec 10, 2020
  15. 6/7 diffcore-rename: simplify and accelerate register_rename_src()Elijah Newren via GitGitGadget, Dec 6, 2020
  16. Taylor BlauDec 9, 2020
  17. Elijah NewrenDec 10, 2020
  18. Taylor BlauDec 10, 2020
  19. Junio C HamanoDec 10, 2020
  20. 5/7 diffcore-rename: reduce jumpiness in progress countersElijah Newren via GitGitGadget, Dec 6, 2020
  21. Taylor BlauDec 9, 2020
  22. Junio C HamanoDec 10, 2020
  23. 3/7 diffcore-rename: rename num_create to num_targetsElijah Newren via GitGitGadget, Dec 6, 2020
  24. Junio C HamanoDec 10, 2020
  25. Elijah NewrenDec 10, 2020
  26. 1/7 diffcore-rename: avoid usage of global in too_many_rename_candidates()Elijah Newren via GitGitGadget, Dec 6, 2020
  27. Taylor BlauDec 9, 2020
  28. 0/9 diffcore-rename improvementsElijah Newren via GitGitGadget, Dec 11, 2020
  29. 1/9 diffcore-rename: rename num_create to num_destinationsElijah Newren via GitGitGadget, Dec 11, 2020
  30. 2/9 diffcore-rename: avoid usage of global in too_many_rename_candidates()Elijah Newren via GitGitGadget, Dec 11, 2020
  31. 3/9 diffcore-rename: simplify limit checkElijah Newren via GitGitGadget, Dec 11, 2020
  32. 8/9 diffcore-rename: accelerate rename_dst setupElijah Newren via GitGitGadget, Dec 11, 2020
  33. 7/9 diffcore-rename: simplify and accelerate register_rename_src()Elijah Newren via GitGitGadget, Dec 11, 2020
  34. 4/9 diffcore-rename: reduce jumpiness in progress countersElijah Newren via GitGitGadget, Dec 11, 2020
  35. 9/9 diffcore-rename: remove unneccessary duplicate entry checksElijah Newren via GitGitGadget, Dec 11, 2020
  36. Christian CouderDec 29, 2020
  37. Elijah NewrenDec 29, 2020
  38. 5/9 t4058: add more tests and documentation for duplicate tree entry handlingElijah Newren via GitGitGadget, Dec 11, 2020
  39. 6/9 t4058: explore duplicate tree entry handling in a bit more detailElijah Newren via GitGitGadget, Dec 11, 2020
  40. Ævar Arnfjörð BjarmasonApr 21, 2021
  41. Elijah NewrenApr 21, 2021
  42. 0/9 diffcore-rename improvementsElijah Newren via GitGitGadget, Dec 29, 2020
  43. 1/9 diffcore-rename: rename num_create to num_destinationsElijah Newren via GitGitGadget, Dec 29, 2020
  44. 8/9 diffcore-rename: accelerate rename_dst setupElijah Newren via GitGitGadget, Dec 29, 2020
  45. 7/9 diffcore-rename: simplify and accelerate register_rename_src()Elijah Newren via GitGitGadget, Dec 29, 2020
  46. 2/9 diffcore-rename: avoid usage of global in too_many_rename_candidates()Elijah Newren via GitGitGadget, Dec 29, 2020
  47. 3/9 diffcore-rename: simplify limit checkElijah Newren via GitGitGadget, Dec 29, 2020
  48. Başar UğurNov 9, 2021
  49. Elijah NewrenNov 10, 2021
  50. Başar UğurNov 11, 2021
  51. Elijah NewrenNov 11, 2021
  52. 4/9 diffcore-rename: reduce jumpiness in progress countersElijah Newren via GitGitGadget, Dec 29, 2020
  53. 9/9 diffcore-rename: remove unnecessary duplicate entry checksElijah Newren via GitGitGadget, Dec 29, 2020
  54. 6/9 t4058: explore duplicate tree entry handling in a bit more detailElijah Newren via GitGitGadget, Dec 29, 2020
  55. 5/9 t4058: add more tests and documentation for duplicate tree entry handlingElijah Newren via GitGitGadget, Dec 29, 2020

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.