From: Junio C Hamano <gitster@pobox.com>
To: Elijah Newren <newren@gmail.com>
Cc: pcasaretto via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, Paulo Casaretto <pcasaretto@gmail.com>,
pcasaretto <paulo.casaretto@shopify.com>
Subject: Re: [PATCH v2 2/2] range-diff: add configurable memory limit for cost matrix
Date: Thu, 28 Aug 2025 14:22:45 -0700 [thread overview]
Message-ID: <xmqqiki7ta3e.fsf@gitster.g> (raw)
In-Reply-To: <CABPp-BEDje5dYZHEyYMN6j_LdR5CqRN1cxc0riRK06qK-OxiTA@mail.gmail.com> (Elijah Newren's message of "Thu, 28 Aug 2025 10:04:53 -0700")
Elijah Newren <newren@gmail.com> writes:
> <gitgitgadget@gmail.com> wrote:
>>
>> From: pcasaretto <paulo.casaretto@shopify.com>
>> Signed-off-by: Paulo Casaretto <paulo.casaretto@shopify.com>
>
> The names (and emails) in these should match; I believe the name in
> the From field is set by Gitgitgadget based on your profile settings;
> see https://github.com/settings/profile and set your name there.
>
>> static void get_correspondences(struct string_list *a, struct string_list *b,
>> - int creation_factor)
>> + int creation_factor, size_t max_memory)
>> {
>> int n = a->nr + b->nr;
>> int *cost, c, *a2b, *b2a;
>> int i, j;
>> -
>> - ALLOC_ARRAY(cost, st_mult(n, n));
>> + size_t cost_size = st_mult(n, n);
>> + size_t cost_bytes = st_mult(sizeof(int), cost_size);
>> + if (cost_bytes >= max_memory) {
>> + struct strbuf cost_str = STRBUF_INIT;
>> + struct strbuf max_str = STRBUF_INIT;
>> + strbuf_humanise_bytes(&cost_str, cost_bytes);
>> + strbuf_humanise_bytes(&max_str, max_memory);
>> + die(_("range-diff: unable to compute the range-diff, since it "
>> + "exceeds the maximum memory for the cost matrix: %s "
>> + "(%"PRIuMAX" bytes) needed, %s (%"PRIuMAX" bytes) available"),
>
> available? I'm worried the error message will report in users
> checking system memory, claiming they have 14GB available on their
> system, and then reporting a "bug".
>
> Perhaps something like:
>
> + "(%"PRIuMAX" bytes) needed, limited to %s
> (%"PRIuMAX" bytes)"),
Sounds like a good idea.
I am not a huge fan of configuration variables that do not have a
command line option. Assuming that it is not like you'd be doing
overly huge range-diff that would not fit your memory every day,
shouldn't we start this with a command line option without a
configuration variable to gauge how useful it would be for users
with such a need, and then after it proves useful and we identify a
workflow where a user would be passing this option all the time, add
a configuration to allow it always be in effect (with command line
override still available)?
next prev parent reply other threads:[~2025-08-28 21:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 17:18 [PATCH] range-diff: add configurable memory limit for cost matrix Paulo Casaretto via GitGitGadget
2025-08-26 19:18 ` Junio C Hamano
2025-08-28 8:38 ` [PATCH v2 0/2] " Paulo Casaretto via GitGitGadget
2025-08-28 8:38 ` [PATCH v2 1/2] range-diff: reorder options lexicographically pcasaretto via GitGitGadget
2025-08-28 15:21 ` Junio C Hamano
2025-08-28 17:12 ` Elijah Newren
2025-08-29 10:56 ` Paulo L F Casaretto
2025-08-29 15:15 ` Junio C Hamano
2025-08-28 8:38 ` [PATCH v2 2/2] range-diff: add configurable memory limit for cost matrix pcasaretto via GitGitGadget
2025-08-28 17:04 ` Elijah Newren
2025-08-28 21:22 ` Junio C Hamano [this message]
2025-08-28 21:34 ` Elijah Newren
2025-08-28 21:45 ` Junio C Hamano
2025-08-29 11:00 ` [PATCH v3] " Paulo Casaretto via GitGitGadget
2025-08-29 15:21 ` Elijah Newren
2025-08-29 16:33 ` Junio C Hamano
2025-08-29 15:40 ` Junio C Hamano
2025-08-29 16:02 ` [PATCH v4] " Paulo Casaretto via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqiki7ta3e.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=newren@gmail.com \
--cc=paulo.casaretto@shopify.com \
--cc=pcasaretto@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).