From: Taylor Blau <me@ttaylorr.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, peff@peff.net
Subject: Re: [PATCH 1/5] builtin/repack.c: do not repack single packs with --geometric
Date: Fri, 5 Mar 2021 14:27:41 -0500 [thread overview]
Message-ID: <YEKGLfUM1DSHk74B@nand.local> (raw)
In-Reply-To: <xmqqv9a59ztd.fsf@gitster.c.googlers.com>
On Fri, Mar 05, 2021 at 11:15:58AM -0800, Junio C Hamano wrote:
> Taylor Blau <me@ttaylorr.com> writes:
>
> > Loosen the guard to only stop when there aren't any packs, and let the
> > rest of the code do the right thing. Add a test to ensure that this is
> > the case.
> >
> > Noticed-by: Junio C Hamano <gitster@pobox.com>
>
> I do not think I "noticed" anything, though.
Well, I clearly didn't notice it, so I'm happy to pass the buck to you.
> > - if (geometry->pack_nr <= 1) {
> > + if (!geometry->pack_nr) {
> > geometry->split = geometry->pack_nr;
> > return;
> > }
>
> When pack_nr is 0, split is set to 0. Otherwise we compute the
> split the usual way in the new code. Let's see the post-context of
> the above code and figure out what happens when pack_nr is 1.
>
> [snip]
>
> I however wonder if it expresses the intent more clearly if you did
> this upfront, instead of forcing the readers to go through the code.
>
> if (geometry->pack_nr <= 1) {
> - geometry->split = geometry->pack_nr;
> + geometry->split = 0;
> return;
> }
>
> That is, "when there is no existing packs, or just one pack, we
> split at 0"
Hmm. I originally wrote the patch as:
if (geometry->pack_nr <= 1) {
geometry->split = 0;
return;
}
instead of only when geometry->pack_nr == 0. But I was pretty sure that
the code below was doing the right thing even for geometry->pack_nr ==
1, and so I decided to avoid making this non-special case "special" by
returning early.
I could see arguments in both directions. But I may be biased as the
author, so I'd rather defer to your judgement instead.
> The code that gets affected by the setting of "split" is this piece
> in the caller, cmd_repack():
>
> if (geometry) {
> FILE *in = xfdopen(cmd.in, "w");
> for (i = 0; i < geometry->split; i++)
> fprintf(in, "%s\n", pack_basename(geometry->pack[i]));
> for (i = geometry->split; i < geometry->pack_nr; i++)
> fprintf(in, "^%s\n", pack_basename(geometry->pack[i]));
> fclose(in);
> }
>
> When split == 0, we end up feeding no positive packs and all
> negative packs, which results in nothing to pack. I wonder if we
> can optimize out the spawning of the pack-object process, but that
> is probalby optimizing for a wrong case.
Yeah, I think the earlier optimization (avoiding repacking the contents
of a single pack) is more important than not opening pack objects here.
But the next patch demonstrates why we can't do this: we care about
loose objects, which we may still pick up even if split == 0.
Thanks,
Taylor
next prev parent reply other threads:[~2021-03-05 19:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-05 15:21 [PATCH 0/5] clean-ups to geometric repacking Taylor Blau
2021-03-05 15:21 ` [PATCH 1/5] builtin/repack.c: do not repack single packs with --geometric Taylor Blau
2021-03-05 19:15 ` Junio C Hamano
2021-03-05 19:27 ` Taylor Blau [this message]
2021-03-05 19:30 ` Taylor Blau
2021-03-05 15:21 ` [PATCH 2/5] t7703: test --geometric repack with loose objects Taylor Blau
2021-03-05 15:21 ` [PATCH 3/5] builtin/repack.c: assign pack split later Taylor Blau
2021-03-05 15:21 ` [PATCH 4/5] builtin/repack.c: be more conservative with unsigned overflows Taylor Blau
2021-03-05 19:32 ` Junio C Hamano
2021-03-05 19:41 ` Taylor Blau
2021-03-10 21:00 ` Jeff King
2021-03-05 15:22 ` [PATCH 5/5] builtin/repack.c: reword comment around pack-objects flags Taylor Blau
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=YEKGLfUM1DSHk74B@nand.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.