From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 5/6] odb/source: introduce generic object counting
Date: Wed, 11 Mar 2026 07:44:25 +0100 [thread overview]
Message-ID: <abEPSZdahq50L3aF@pks.im> (raw)
In-Reply-To: <xmqqfr67vahm.fsf@gitster.g>
On Tue, Mar 10, 2026 at 10:51:33AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
>
> > +static int odb_source_files_count_objects(struct odb_source *source,
> > + enum odb_count_objects_flags flags,
> > + unsigned long *out)
> > +{
> > + struct odb_source_files *files = odb_source_files_downcast(source);
> > + unsigned long count;
> > + int ret;
> > +
> > + ret = packfile_store_count_objects(files->packed, flags, &count);
> > + if (ret < 0)
> > + goto out;
> > +
> > + if (!(flags & ODB_COUNT_OBJECTS_APPROXIMATE)) {
> > + unsigned long loose_count;
> > +
> > + ret = odb_source_loose_count_objects(source, flags, &loose_count);
> > + if (ret < 0)
> > + goto out;
> > +
> > + count += loose_count;
> > + }
> > +
> > + *out = count;
> > + ret = 0;
> > +
> > +out:
> > + return ret;
> > +}
>
> The design to assume that the majority of objects should be in the
> packfiles and the number of loose objects can be ignored when we are
> getting approximation is inherited from the world before this
> series, I think, which is a valid choice for this series to make.
>
> As your "get an approximate count of loose objects" counts a single
> shared fully, instead of punting as soon as the limit is hit, we
> could ask that function and add it in when the APPROXIMATE flag is
> passed, and get a bit more accurate number cheaply even when we are
> approximating. I am not sure what the pros and cons of doing so
> myself, but you may already have thought about it and rejected it,
> perhaps?
Yeah, I was very torn on this myself, and I switched back and forth
multiple times. I don't really think there is a large downside if we
started to also count loose objects here. The performance overhead
should be negligible, and it may arrive at a result that is closer to
the real world.
But the loose object counting approximation is somewhat vague overall
with the way we extrapolate the object count, and as you mentioned it
matches the old semantics to not include loose objects. So that's why I
decided against including it, so that we retain semantics.
That being said, with the current set of users it doesn't really matter
too much which of both approaches we pick.
Patrick
next prev parent reply other threads:[~2026-03-11 6:44 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 15:18 [PATCH 0/6] odb: introduce generic object counting Patrick Steinhardt
2026-03-10 15:18 ` [PATCH 1/6] odb: stop including "odb/source.h" Patrick Steinhardt
2026-03-10 15:18 ` [PATCH 2/6] packfile: extract logic to count number of objects Patrick Steinhardt
2026-03-11 12:41 ` Toon Claes
2026-03-11 13:55 ` Patrick Steinhardt
2026-03-10 15:18 ` [PATCH 3/6] object-file: extract logic to approximate object count Patrick Steinhardt
2026-03-10 17:44 ` Junio C Hamano
2026-03-11 12:47 ` Toon Claes
2026-03-11 13:58 ` Patrick Steinhardt
2026-03-10 15:18 ` [PATCH 4/6] object-file: generalize counting objects Patrick Steinhardt
2026-03-11 13:53 ` Toon Claes
2026-03-11 14:01 ` Patrick Steinhardt
2026-03-10 15:18 ` [PATCH 5/6] odb/source: introduce generic object counting Patrick Steinhardt
2026-03-10 17:51 ` Junio C Hamano
2026-03-11 6:44 ` Patrick Steinhardt [this message]
2026-03-11 15:03 ` Toon Claes
2026-03-10 15:18 ` [PATCH 6/6] odb: " Patrick Steinhardt
2026-03-11 15:30 ` Toon Claes
2026-03-12 6:57 ` Patrick Steinhardt
2026-03-12 8:42 ` [PATCH v2 0/6] " Patrick Steinhardt
2026-03-12 8:42 ` [PATCH v2 1/6] odb: stop including "odb/source.h" Patrick Steinhardt
2026-03-12 8:42 ` [PATCH v2 2/6] packfile: extract logic to count number of objects Patrick Steinhardt
2026-03-12 8:42 ` [PATCH v2 3/6] object-file: extract logic to approximate object count Patrick Steinhardt
2026-03-12 8:42 ` [PATCH v2 4/6] object-file: generalize counting objects Patrick Steinhardt
2026-03-12 8:43 ` [PATCH v2 5/6] odb/source: introduce generic object counting Patrick Steinhardt
2026-03-12 8:43 ` [PATCH v2 6/6] odb: " Patrick Steinhardt
2026-03-13 11:52 ` [PATCH v2 0/6] " Toon Claes
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=abEPSZdahq50L3aF@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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