From: Taylor Blau <me@ttaylorr.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Taylor Blau <me@ttaylorr.com>,
git@vger.kernel.org, dstolee@microsoft.com, jrnieder@gmail.com,
peff@peff.net
Subject: Re: [PATCH v2 01/20] pack-revindex: introduce a new API
Date: Thu, 14 Jan 2021 12:06:20 -0500 [thread overview]
Message-ID: <YAB6DNk4wPBVbGtU@nand.local> (raw)
In-Reply-To: <xmqq1reoypzy.fsf@gitster.c.googlers.com>
On Wed, Jan 13, 2021 at 10:46:57PM -0800, Junio C Hamano wrote:
> Taylor Blau <me@ttaylorr.com> writes:
>
> > +/*
> > + * offset_to_pack_pos converts an object offset to a pack position. This
> > + * function returns zero on success, and a negative number otherwise. The
> > + * parameter 'pos' is usable only on success.
> > + *
> > + * If the reverse index has not yet been loaded, this function loads it lazily,
> > + * and returns an negative number if an error was encountered.
>
> It is somewhat strange to see a function that yields a non-negative
> "position" on success and a negative value to signal a failure to
> have a separate pointer to the location to receive the true return
> value. Do we truly care the upper half of "uint32_t" (in other
> words, do we seriously want to support more than 2G positions in a
> pack)?
I don't think that we care about that as much as we do about potential
misuse of a signed return value. There are indeed a couple of spots
where a potential negative return value is ignored, and then used to
lookup an object in a pack, or some such.
And that's part of the goal of this API: we have strict guidelines about
when the output parameter is and isn't usable. That makes it more
difficult to accidentally use an uninitialized value / negative number.
> What I'm trying to get at is that [...] is more natural than [...] but
> now I wrote it down and laid it out in front of my eyes, the latter
> does not look too bad.
OK, good :-).
> ... later comes back after reading through the series ...
>
> The new callers all looked quite nice to eyes. Because we
> discourage assignment inside if() condition, the converted
> result does not make the code more verbose than the
> original. In fact, it makes it even clearer that we are
> checking for an error return from a function call.
>
> Quite nice.
Thank you :-D.
> > + * This function runs in time O(log N) with the number of objects in the pack.
>
> Is it a good idea to commit to such performance characteristics as a
> promise to callers like this (the comment applies to all three
> functions)?
>
> It depends on how a developer is helped by this comment when
> deciding whether to use this function, or find other ways, to
> implement what s/he wants to do.
I don't mind it. If they all had the same performance characteristics, I
wouldn't be for it, but since they don't, I think that it's good to
know. Peff suggested this back in [1].
Thanks,
Taylor
[1]: https://lore.kernel.org/git/X%2F1guCOGWybOzIS7@coredump.intra.peff.net/
next prev parent reply other threads:[~2021-01-14 17:12 UTC|newest]
Thread overview: 121+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-08 18:16 [PATCH 00/20] pack-revindex: prepare for on-disk reverse index Taylor Blau
2021-01-08 18:16 ` [PATCH 01/20] pack-revindex: introduce a new API Taylor Blau
2021-01-12 8:41 ` Jeff King
2021-01-12 9:41 ` Jeff King
2021-01-12 16:27 ` Taylor Blau
2021-01-13 8:06 ` Junio C Hamano
2021-01-13 8:54 ` Junio C Hamano
2021-01-13 13:17 ` Jeff King
2021-01-13 16:23 ` Taylor Blau
2021-01-08 18:16 ` [PATCH 02/20] write_reuse_object(): convert to new revindex API Taylor Blau
2021-01-12 8:47 ` Jeff King
2021-01-12 16:31 ` Taylor Blau
2021-01-13 13:02 ` Jeff King
2021-01-08 18:16 ` [PATCH 03/20] write_reused_pack_one(): " Taylor Blau
2021-01-12 8:50 ` Jeff King
2021-01-12 16:34 ` Taylor Blau
2021-01-08 18:16 ` [PATCH 04/20] write_reused_pack_verbatim(): " Taylor Blau
2021-01-12 8:50 ` Jeff King
2021-01-08 18:17 ` [PATCH 05/20] check_object(): " Taylor Blau
2021-01-11 11:43 ` Derrick Stolee
2021-01-11 16:15 ` Taylor Blau
2021-01-12 8:54 ` Jeff King
2021-01-12 8:51 ` Jeff King
2021-01-08 18:17 ` [PATCH 06/20] bitmap_position_packfile(): " Taylor Blau
2021-01-08 18:17 ` [PATCH 07/20] show_objects_for_type(): " Taylor Blau
2021-01-12 8:57 ` Jeff King
2021-01-12 16:35 ` Taylor Blau
2021-01-08 18:17 ` [PATCH 08/20] get_size_by_pos(): " Taylor Blau
2021-01-08 18:17 ` [PATCH 09/20] try_partial_reuse(): " Taylor Blau
2021-01-12 9:06 ` Jeff King
2021-01-12 16:47 ` Taylor Blau
2021-01-08 18:17 ` [PATCH 10/20] rebuild_existing_bitmaps(): " Taylor Blau
2021-01-08 18:17 ` [PATCH 11/20] get_delta_base_oid(): " Taylor Blau
2021-01-08 18:17 ` [PATCH 12/20] retry_bad_packed_offset(): " Taylor Blau
2021-01-08 18:17 ` [PATCH 13/20] packed_object_info(): " Taylor Blau
2021-01-12 9:11 ` Jeff King
2021-01-12 16:51 ` Taylor Blau
2021-01-08 18:17 ` [PATCH 14/20] unpack_entry(): " Taylor Blau
2021-01-12 9:22 ` Jeff King
2021-01-12 16:56 ` Taylor Blau
2021-01-08 18:17 ` [PATCH 15/20] for_each_object_in_pack(): " Taylor Blau
2021-01-08 18:17 ` [PATCH 16/20] builtin/gc.c: guess the size of the revindex Taylor Blau
2021-01-11 11:52 ` Derrick Stolee
2021-01-11 16:23 ` Taylor Blau
2021-01-11 17:09 ` Derrick Stolee
2021-01-12 9:28 ` Jeff King
2021-01-08 18:17 ` [PATCH 17/20] pack-revindex: remove unused 'find_pack_revindex()' Taylor Blau
2021-01-08 18:17 ` [PATCH 18/20] pack-revindex: remove unused 'find_revindex_position()' Taylor Blau
2021-01-11 11:57 ` Derrick Stolee
2021-01-11 16:27 ` Taylor Blau
2021-01-11 17:11 ` Derrick Stolee
2021-01-12 9:32 ` Jeff King
2021-01-12 16:59 ` Taylor Blau
2021-01-13 13:05 ` Jeff King
2021-01-08 18:18 ` [PATCH 19/20] pack-revindex: hide the definition of 'revindex_entry' Taylor Blau
2021-01-11 11:57 ` Derrick Stolee
2021-01-12 9:34 ` Jeff King
2021-01-08 18:18 ` [PATCH 20/20] pack-revindex.c: avoid direct revindex access in 'offset_to_pack_pos()' Taylor Blau
2021-01-12 9:37 ` Jeff King
2021-01-12 17:02 ` Taylor Blau
2021-01-11 12:07 ` [PATCH 00/20] pack-revindex: prepare for on-disk reverse index Derrick Stolee
2021-01-11 16:30 ` Taylor Blau
2021-01-11 17:15 ` Derrick Stolee
2021-01-11 17:29 ` Taylor Blau
2021-01-11 18:40 ` Junio C Hamano
2021-01-12 9:45 ` Jeff King
2021-01-12 17:07 ` Taylor Blau
2021-01-13 0:23 ` Junio C Hamano
2021-01-13 0:52 ` Taylor Blau
2021-01-13 2:15 ` Junio C Hamano
2021-01-13 3:23 ` Taylor Blau
2021-01-13 8:21 ` Junio C Hamano
2021-01-13 13:13 ` Jeff King
2021-01-13 15:34 ` Taylor Blau
2021-01-13 20:06 ` Junio C Hamano
2021-01-13 20:13 ` Taylor Blau
2021-01-13 20:22 ` Jeff King
2021-01-13 22:23 ` [PATCH v2 " Taylor Blau
2021-01-13 22:23 ` [PATCH v2 01/20] pack-revindex: introduce a new API Taylor Blau
2021-01-14 6:46 ` Junio C Hamano
2021-01-14 12:00 ` Derrick Stolee
2021-01-14 17:06 ` Taylor Blau [this message]
2021-01-14 19:19 ` Jeff King
2021-01-14 20:47 ` Junio C Hamano
2021-01-13 22:23 ` [PATCH v2 02/20] write_reuse_object(): convert to new revindex API Taylor Blau
2021-01-13 22:23 ` [PATCH v2 03/20] write_reused_pack_one(): " Taylor Blau
2021-01-13 22:23 ` [PATCH v2 04/20] write_reused_pack_verbatim(): " Taylor Blau
2021-01-13 22:23 ` [PATCH v2 05/20] check_object(): " Taylor Blau
2021-01-13 22:23 ` [PATCH v2 06/20] bitmap_position_packfile(): " Taylor Blau
2021-01-13 22:23 ` [PATCH v2 07/20] show_objects_for_type(): " Taylor Blau
2021-01-13 22:24 ` [PATCH v2 08/20] get_size_by_pos(): " Taylor Blau
2021-01-13 22:24 ` [PATCH v2 09/20] try_partial_reuse(): " Taylor Blau
2021-01-13 22:24 ` [PATCH v2 10/20] rebuild_existing_bitmaps(): " Taylor Blau
2021-01-13 22:24 ` [PATCH v2 11/20] get_delta_base_oid(): " Taylor Blau
2021-01-13 22:24 ` [PATCH v2 12/20] retry_bad_packed_offset(): " Taylor Blau
2021-01-13 22:24 ` [PATCH v2 13/20] packed_object_info(): " Taylor Blau
2021-01-13 22:24 ` [PATCH v2 14/20] unpack_entry(): " Taylor Blau
2021-01-13 22:24 ` [PATCH v2 15/20] for_each_object_in_pack(): " Taylor Blau
2021-01-14 6:43 ` Junio C Hamano
2021-01-14 17:00 ` Taylor Blau
2021-01-14 19:33 ` Jeff King
2021-01-14 20:11 ` Jeff King
2021-01-14 20:15 ` Taylor Blau
2021-01-15 2:22 ` Junio C Hamano
2021-01-15 2:29 ` Taylor Blau
2021-01-14 20:51 ` Junio C Hamano
2021-01-13 22:24 ` [PATCH v2 16/20] builtin/gc.c: guess the size of the revindex Taylor Blau
2021-01-14 6:33 ` Junio C Hamano
2021-01-14 16:53 ` Taylor Blau
2021-01-14 19:43 ` Jeff King
2021-01-13 22:24 ` [PATCH v2 17/20] pack-revindex: remove unused 'find_pack_revindex()' Taylor Blau
2021-01-13 22:25 ` [PATCH v2 18/20] pack-revindex: remove unused 'find_revindex_position()' Taylor Blau
2021-01-14 6:42 ` Junio C Hamano
2021-01-13 22:25 ` [PATCH v2 19/20] pack-revindex: hide the definition of 'revindex_entry' Taylor Blau
2021-01-13 22:25 ` [PATCH v2 20/20] pack-revindex.c: avoid direct revindex access in 'offset_to_pack_pos()' Taylor Blau
2021-01-14 6:42 ` Junio C Hamano
2021-01-14 16:56 ` Taylor Blau
2021-01-14 19:51 ` [PATCH v2 00/20] pack-revindex: prepare for on-disk reverse index Jeff King
2021-01-14 20:53 ` Junio C Hamano
2021-01-15 9:32 ` Jeff King
2021-01-15 9:33 ` Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YAB6DNk4wPBVbGtU@nand.local \
--to=me@ttaylorr.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).