From: Jeff King <peff@peff.net>
To: Thomas Rast <tr@thomasrast.ch>
Cc: git@vger.kernel.org, "Vicent Martí" <vicent@github.com>
Subject: Re: [PATCH v3 11/21] pack-objects: use bitmaps when packing objects
Date: Sat, 21 Dec 2013 08:15:03 -0500 [thread overview]
Message-ID: <20131221131502.GA10123@sigill.intra.peff.net> (raw)
In-Reply-To: <87zjock6if.fsf@linux-1gf2.Speedport_W723_V_Typ_A_1_00_098>
On Sat, Dec 07, 2013 at 04:47:20PM +0100, Thomas Rast wrote:
> > +static off_t write_reused_pack(struct sha1file *f)
> > +{
> > + uint8_t buffer[8192];
>
> We usually just call this 'unsigned char'. I can see why this would be
> more portable, but git would already fall apart badly on an architecture
> where char is not 8 bits.
I think it's worth switching just for consistency with the rest of git.
Fixed.
> } + packfile_size = write_reused_pack(f);
> } + if (!packfile_size)
> } + die_errno("failed to re-use existing pack");
>
> So if you just died here, when the error happens, you could take the
> chance to tell the user _which_ syscall failed.
Yeah, agreed (and especially the fact that we may get bogus errno
values). Fixed.
> Not your fault, but sha1write() is an odd function -- it purportedly is
>
> int sha1write(struct sha1file *f, const void *buf, unsigned int count);
>
> but it can only return 0. This goes back all the way to c38138c
> (git-pack-objects: write the pack files with a SHA1 csum, 2005-06-26).
It looks like there's exactly one site that checks its return value, and
it's just to die. We should drop the return value from sha1write
entirely to make it clear that it dies on error. But that's orthogonal
to this series.
> > -static int add_object_entry(const unsigned char *sha1, enum object_type type,
> > - const char *name, int exclude)
> > +static int add_object_entry_1(const unsigned char *sha1, enum object_type type,
> > + int flags, uint32_t name_hash,
> > + struct packed_git *found_pack, off_t found_offset)
> [...]
> This function makes my head spin, and you're indenting it yet another
> level.
Yeah. In addition, the use of the "flags" here is somewhat questionable.
We use them for internal values in the call from add_object_entry to
add_object_entry_1. But we also pass the latter as a traversal callback,
meaning that what it would get in "flags" is totally different. It's not
actually a bug in the current code, since the bitmap traversal always
passes empty flags, but it's still rather confusing.
> If it's not too much work, can you split it into the three parts that it
> really is? IIUC it boils down to
>
> do we have this already?
> possibly apply 'exclude', then return
> are we coming from a call path that doesn't tell us which pack to take
> it from?
> find _all_ instances in packs
> check if any of them are local .keep packs
> if so, return
> construct a packlist entry to taste
I did this split. By itself, I was on the fence, as there are actually
some interdependencies between the three parts that make it hairy.
But then I realized that instead of making the weird relationship
between add_object_entry and add_object_entry_1, we can simply make a
new function that composes the functions differently.
So we get:
+static int add_object_entry_from_bitmap(const unsigned char *sha1,
+ enum object_type type,
+ int flags, uint32_t name_hash,
+ struct packed_git *pack, off_t offset)
+{
+ uint32_t index_pos;
+
+ if (have_duplicate_entry(sha1, 0, &index_pos))
+ return 0;
+
+ create_object_entry(sha1, type, name_hash, 0, 0, index_pos, pack, offset);
+
+ display_progress(progress_state, to_pack.nr_objects);
+ return 1;
+}
[...]
+ traverse_bitmap_commit_list(&add_object_entry_from_bitmap);
which makes much more sense.
-Peff
next prev parent reply other threads:[~2013-12-21 13:15 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-14 12:41 [PATCH v3 0/21] pack bitmaps Jeff King
2013-11-14 12:42 ` [PATCH v3 01/21] sha1write: make buffer const-correct Jeff King
2013-11-14 12:42 ` [PATCH v3 02/21] revindex: Export new APIs Jeff King
2013-11-14 12:42 ` [PATCH v3 03/21] pack-objects: Refactor the packing list Jeff King
2013-11-14 12:43 ` [PATCH v3 04/21] pack-objects: factor out name_hash Jeff King
2013-11-14 12:43 ` [PATCH v3 05/21] revision: allow setting custom limiter function Jeff King
2013-11-14 12:43 ` [PATCH v3 06/21] sha1_file: export `git_open_noatime` Jeff King
2013-11-14 12:43 ` [PATCH v3 07/21] compat: add endianness helpers Jeff King
2013-11-14 12:43 ` [PATCH v3 08/21] ewah: compressed bitmap implementation Jeff King
2013-11-14 12:44 ` [PATCH v3 09/21] documentation: add documentation for the bitmap format Jeff King
2013-11-14 12:44 ` [PATCH v3 10/21] pack-bitmap: add support for bitmap indexes Jeff King
2013-11-24 21:36 ` Thomas Rast
2013-11-25 15:04 ` [PATCH] Document khash Thomas Rast
2013-11-28 10:35 ` Jeff King
2013-11-27 9:08 ` [PATCH v3 10/21] pack-bitmap: add support for bitmap indexes Karsten Blees
2013-11-28 10:38 ` Jeff King
2013-12-03 14:40 ` Karsten Blees
2013-12-03 18:21 ` Jeff King
2013-12-07 20:52 ` Karsten Blees
2013-11-29 21:21 ` Thomas Rast
2013-12-02 16:12 ` Jeff King
2013-12-02 20:36 ` Junio C Hamano
2013-12-02 20:47 ` Jeff King
2013-12-02 21:43 ` Junio C Hamano
2013-11-14 12:45 ` [PATCH v3 11/21] pack-objects: use bitmaps when packing objects Jeff King
2013-12-07 15:47 ` Thomas Rast
2013-12-21 13:15 ` Jeff King [this message]
2013-11-14 12:45 ` [PATCH v3 12/21] rev-list: add bitmap mode to speed up object lists Jeff King
2013-12-07 16:05 ` Thomas Rast
2013-11-14 12:45 ` [PATCH v3 13/21] pack-objects: implement bitmap writing Jeff King
2013-12-07 16:32 ` Thomas Rast
2013-12-21 13:17 ` Jeff King
2013-11-14 12:45 ` [PATCH v3 14/21] repack: stop using magic number for ARRAY_SIZE(exts) Jeff King
2013-12-07 16:34 ` Thomas Rast
2013-11-14 12:46 ` [PATCH v3 15/21] repack: turn exts array into array-of-struct Jeff King
2013-12-07 16:34 ` Thomas Rast
2013-11-14 12:46 ` [PATCH v3 16/21] repack: handle optional files created by pack-objects Jeff King
2013-12-07 16:35 ` Thomas Rast
2013-11-14 12:46 ` [PATCH v3 17/21] repack: consider bitmaps when performing repacks Jeff King
2013-12-07 16:37 ` Thomas Rast
2013-11-14 12:46 ` [PATCH v3 18/21] count-objects: recognize .bitmap in garbage-checking Jeff King
2013-12-07 16:38 ` Thomas Rast
2013-11-14 12:46 ` [PATCH v3 19/21] t: add basic bitmap functionality tests Jeff King
2013-12-07 16:43 ` Thomas Rast
2013-12-21 13:22 ` Jeff King
2013-11-14 12:48 ` [PATCH v3 20/21] t/perf: add tests for pack bitmaps Jeff King
2013-12-07 16:51 ` Thomas Rast
2013-12-21 13:40 ` Jeff King
2013-11-14 12:48 ` [PATCH v3 21/21] pack-bitmap: implement optional name_hash cache Jeff King
2013-12-07 16:59 ` Thomas Rast
2013-11-14 19:19 ` [PATCH v3 0/21] pack bitmaps Ramsay Jones
2013-11-14 21:33 ` Jeff King
2013-11-14 23:09 ` Ramsay Jones
2013-11-18 21:16 ` Ramsay Jones
2013-11-16 10:28 ` Thomas Rast
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=20131221131502.GA10123@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=tr@thomasrast.ch \
--cc=vicent@github.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).