From: Jeff King <peff@peff.net>
To: John Keeping <john@keeping.me.uk>
Cc: "Duy Nguyen" <pclouds@gmail.com>,
"Дилян Палаузов" <dilyan.palauzov@aegee.org>,
"Git Mailing List" <git@vger.kernel.org>
Subject: Re: git pull & git gc
Date: Wed, 18 Mar 2015 17:04:58 -0400 [thread overview]
Message-ID: <20150318210458.GA3376@peff.net> (raw)
In-Reply-To: <20150318145815.GN1369@serenity.lan>
On Wed, Mar 18, 2015 at 02:58:15PM +0000, John Keeping wrote:
> On Wed, Mar 18, 2015 at 09:41:59PM +0700, Duy Nguyen wrote:
> > On Wed, Mar 18, 2015 at 9:33 PM, Duy Nguyen <pclouds@gmail.com> wrote:
> > > If not, I made some mistake in analyzing this and we'll start again.
> >
> > I did make one mistake, the first "gc" should have reduced the number
> > of loose objects to zero. Why didn't it.? I'll come back to this
> > tomorrow if nobody finds out first :)
>
> Most likely they are not referenced by anything but are younger than 2
> weeks.
>
> I saw a similar issue with automatic gc triggering after every operation
> when I did something equivalent to:
>
> git add <lots of files>
> git commit
> git reset --hard HEAD^
>
> which creates a log of unreachable objects which are not old enough to
> be pruned.
Yes, this is almost certainly the problem. Though to be pedantic, the
command above will still have a reflog entry, so the objects will be
reachable (and packed). But there are other variants that don't leave
the objects reachable from even reflogs.
I don't know if there is an easy way around this. Auto-gc's object count
is making the assumption that running the gc will reduce the number of
objects, but obviously it does not always do so. We could do a more
thorough check and find the number of actual packable and prune-able
objects. The "prune-able" part of that is easy; just omit objects from
the count that are newer than 2 weeks. But "packable" is expensive. You
would have to compute reachability by walking from the tips. That can
take tens of seconds on a large repo.
You could perhaps cut off the walk early when you hit a packed commit
(this does not strictly imply that all of the related objects are
packed, but it would be good enough for a heuristic). But even that is
probably too expensive for "gc --auto".
-Peff
PS Note that in git v2.2.0 and up, prune will leave not only "recent"
unreachable objects, but older objects which are reachable from those
recent ones (so that we keep or prune whole chunks of history, rather
than dropping part and leaving the rest broken). Technically this
exacerbates the problem (we keep more objects), though I doubt it
makes much difference in practice (most chunks of history were
created at similar times, so the mtimes of the whole chunk will be
close together).
next prev parent reply other threads:[~2015-03-18 21:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-18 13:53 git pull & git gc Дилян Палаузов
2015-03-18 14:16 ` Duy Nguyen
2015-03-18 14:23 ` Дилян Палаузов
2015-03-18 14:33 ` Duy Nguyen
2015-03-18 14:41 ` Duy Nguyen
2015-03-18 14:58 ` John Keeping
2015-03-18 21:04 ` Jeff King [this message]
2015-03-19 0:31 ` Duy Nguyen
2015-03-19 1:27 ` Jeff King
2015-03-19 2:01 ` Mike Hommey
2015-03-19 4:14 ` Jeff King
2015-03-19 4:26 ` Mike Hommey
2015-03-19 2:27 ` Junio C Hamano
2015-03-19 4:09 ` Jeff King
2015-03-19 4:15 ` Duy Nguyen
2015-03-19 4:20 ` Jeff King
2015-03-19 4:29 ` Duy Nguyen
2015-03-19 4:34 ` Jeff King
2015-03-19 9:47 ` Duy Nguyen
2015-03-18 14:48 ` Дилян Палаузов
2015-03-18 21:07 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150318210458.GA3376@peff.net \
--to=peff@peff.net \
--cc=dilyan.palauzov@aegee.org \
--cc=git@vger.kernel.org \
--cc=john@keeping.me.uk \
--cc=pclouds@gmail.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).