git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Nicolas Pitre <nico@fluxnic.net>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 2/4] pack v4: add v4_size to struct delta_base_cache_entry
Date: Fri, 13 Sep 2013 20:59:50 +0700	[thread overview]
Message-ID: <CACsJy8DrxQqvKyAH0trd1nDbFTL2Gq7k5O-shK4j8W6PMirNYw@mail.gmail.com> (raw)
In-Reply-To: <alpine.LFD.2.03.1309130913510.20709@syhkavp.arg>

On Fri, Sep 13, 2013 at 8:27 PM, Nicolas Pitre <nico@fluxnic.net> wrote:
> On Thu, 12 Sep 2013, Nguyễn Thái Ngọc Duy wrote:
>
>> The intention is to store flat v4 trees in delta base cache to avoid
>> repeatedly expanding copy sequences in v4 trees. When the user needs
>> to unpack a v4 tree and the tree is found in the cache, the tree will
>> be converted back to canonical format. Future tree_desc interface may
>> skip canonical format and read v4 trees directly.
>>
>> For that to work we need to keep track of v4 tree size after all copy
>> sequences are expanded, which is the purpose of this new field.
>
> Hmmm.... I think this is going in a wrong direction.

Good thing you caught me early. I was planning to implement a better
version of this on the weekend. And you are not wrong about code
maintainability, unpack_entry() so far looks very close to a real
mess.

> Yet, pavkv4 tree walking shouldn't need a cache since there is nothing
> to expand in the end.  Entries should be advanced one by one as they are
> needed.  Granted when converting back to a canonical object we need all
> of them, but eventually this shouldn't be the main mode of operation.

There's another case where one of the base tree is not v4 (the packer
is inefficient, like my index-pack --fix-thin). For trees with leading
zeros in entry mode, we can just do a lossy conversion to v4, but I
wonder if there is a case where we can't even convert to v4 and the v4
treewalk interface has to fall back to canonical format.. I guess that
can't happen.

> However I can see that, as you say, the same base object is repeatedly
> referenced.  This means that we need to parse it over and over again
> just to find the right offset where the needed entries start.  We
> probably end up skipping over the first entries in a tree object
> multiple times.  And that would be true even when the core code learns
> to walk pv4 trees directly.
>
> So here's the beginning of a tree offset cache to mitigate this problem.
> It is incomplete as the cache function is not implemented, etc.  But
> that should give you the idea.

Thanks. I'll have a closer look and maybe complete your patch.
-- 
Duy

  reply	other threads:[~2013-09-13 14:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12 10:38 [PATCH 1/4] pack v4: avoid strlen() in tree_entry_prefix Nguyễn Thái Ngọc Duy
2013-09-12 10:38 ` [PATCH 2/4] pack v4: add v4_size to struct delta_base_cache_entry Nguyễn Thái Ngọc Duy
2013-09-13 13:27   ` Nicolas Pitre
2013-09-13 13:59     ` Duy Nguyen [this message]
2013-09-14  2:06       ` Nicolas Pitre
2013-09-14  4:22         ` Nicolas Pitre
2013-09-15  7:35           ` Duy Nguyen
2013-09-16  4:42             ` Nicolas Pitre
2013-09-16  5:24               ` Duy Nguyen
2013-09-12 10:38 ` [PATCH 3/4] pack v4: cache flattened v4 trees in delta base cache Nguyễn Thái Ngọc Duy
2013-09-12 10:38 ` [PATCH 4/4] pack v4: make use of cached v4 trees when unpacking Nguyễn Thái Ngọc Duy
2013-09-12 13:29 ` [PATCH 5/4] pack v4: convert v4 tree to canonical format if found in base cache Nguyễn Thái Ngọc Duy

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=CACsJy8DrxQqvKyAH0trd1nDbFTL2Gq7k5O-shK4j8W6PMirNYw@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=nico@fluxnic.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 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).