git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] index-pack: prefetch missing REF_DELTA bases
Date: Thu, 16 May 2019 21:09:51 -0400	[thread overview]
Message-ID: <20190517010950.GA30146@sigill.intra.peff.net> (raw)
In-Reply-To: <20190516231509.253998-1-jonathantanmy@google.com>

On Thu, May 16, 2019 at 04:15:09PM -0700, Jonathan Tan wrote:

> > /*
> >  * Second pass:
> >  * - for all non-delta objects, look if it is used as a base for
> >  *   deltas;
> >  * - if used as a base, uncompress the object and apply all deltas,
> >  *   recursively checking if the resulting object is used as a base
> >  *   for some more deltas.
> >  */
> 
> I haven't seen any code that contradicts this comment. And looking at
> the code, for each non-delta object, I think that all deltas are checked
> - regardless of whether they appear before or after that non-delta
> object. (find_ref_delta() does a binary search from 0 to
> nr_ref_deltas, calculated in parse_pack_objects() which happens before
> any resolution of deltas.)
> 
> And find_unresolved_deltas_1() (called from resolve_deltas() indirectly)
> sets the real_type when it resolves a delta, as far as I can tell.
> 
> So there is more than one "resolve deltas" step - resolve_deltas() and
> then fix_unresolved_deltas(). The pre-fetching happens only during the
> latter.

OK, that is better than I realized. But I think there is still one
interesting case: what happens if a thin delta is used as the base for a
non-thin delta (even one that is OFS_DELTA)?

We cannot handle that second delta until the third pass in
fix_unresolved_deltas(), because we do not realize we have the base
until we resolve the thin delta.

Specifically, I wonder:

  - do we pre-fetch it, not realizing that we will soon have the base?
    That's not ideal, but I think is necessary if we pre-fetch (and is
    still a worst case even if we did single on-demand fetches).

  - will we ever append a presumed-thin base to the pack, only to later
    realize that we already have that object, creating a duplicate
    object in the pack? If so, do we handle this correctly when
    generating the index (I know we've had issues in the past and have
    expressly forbidden duplicates from appearing in the index; even
    having a duplicate in the pack stream itself is non-ideal, though,
    as it screws up things like on-disk size calculations).

    Because of the sorting in fix_unresolved_deltas(), I think this
    could easily be prevented if the non-thin delta is OFS_DELTA (by
    just checking for the base in our already-found list of objects
    before we call read_object_file(). But for REF_DELTA, I think we
    have no way of knowing that appending is the wrong thing (and no
    good way of backing it out afterwards).

-Peff

  reply	other threads:[~2019-05-17  1:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14 21:10 [PATCH 0/2] Partial clone fix: handling received REF_DELTA Jonathan Tan
2019-05-14 21:10 ` [PATCH 1/2] t5616: refactor packfile replacement Jonathan Tan
2019-05-15  8:36   ` Johannes Schindelin
2019-05-15 18:22     ` Jonathan Tan
2019-05-14 21:10 ` [PATCH 2/2] index-pack: prefetch missing REF_DELTA bases Jonathan Tan
2019-05-15  8:46   ` Johannes Schindelin
2019-05-15 18:28     ` Jonathan Tan
2019-05-17 18:33       ` Johannes Schindelin
2019-05-15 23:16   ` Jeff King
2019-05-16  1:43     ` Junio C Hamano
2019-05-16  4:04       ` Jeff King
2019-05-16 18:26     ` Jonathan Tan
2019-05-16 21:12       ` Jeff King
2019-05-16 21:30         ` Jonathan Tan
2019-05-16 21:42           ` Jeff King
2019-05-16 23:15             ` Jonathan Tan
2019-05-17  1:09               ` Jeff King [this message]
2019-05-17  1:22                 ` Jeff King
2019-05-17  4:39                   ` Jeff King
2019-05-17  4:42                     ` Jeff King
2019-05-17  7:20                     ` Duy Nguyen
2019-05-17  8:55                       ` Jeff King
2019-05-18 11:39                         ` Duy Nguyen
2019-05-20 23:04                           ` Nicolas Pitre
2019-05-21 21:20                             ` Jeff King
2019-06-03 22:23   ` Jonathan Nieder

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=20190517010950.GA30146@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.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.
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).