git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Michael J Gruber <git@grubix.eu>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 0/4] Test name-rev with small stack
Date: Mon, 11 Sep 2017 14:08:25 -0400	[thread overview]
Message-ID: <20170911180824.gf6jecxpx7d3d4a7@sigill.intra.peff.net> (raw)
In-Reply-To: <9b3275a2-7b47-9ed8-6f1f-dac999c3b46a@grubix.eu>

On Fri, Sep 08, 2017 at 02:33:35PM +0200, Michael J Gruber wrote:

> Looking at it more closely, the solution in cbc60b6720 ("git tag
> --contains: avoid stack overflow", 2014-04-24) seems to be a bit "ad
> hoc" to me:
> 
> First of all, there is more than "tag --contains" that may exceed the
> stack by recursion. So I would expect the solution to be more general,
> and not localised and specialised to builtin/tag.c

At the time, tag was the only one using this depth-first contains
algorithm. It's since been adapted to ref-filter.c, but of course the
stack handling went with it.

Most traversals have a date-sorted queue, so are effectively doing a
breadth-first iteration with no recursion.

> Second, this is a walk, so I'm wondering whether our revision walk
> machinery should be the place to add missing functionality (if any).
> That way, everything would benefit from possible or existing
> improvements there. For example, I think some of our "extra walkers"
> don't heed object replacements. (I need to test more.)

It's possible that name-rev could make better use of the existing
traversal machinery. It's often tough to do so, though, because that
machinery gives you a linearized ordering of the commits. Whereas
something like name-rev really cares about the order that it visits the
commits, because it's building up the names.

It's the same for this "tag --contains" traversal. It _used_ to be a
series of merge-base computations. But by doing a custom traversal, we
can cache incremental results through the graph and avoid walking over
the same bits multiple times. There actually is a way to do it with the
regular breadth-first traversal, but you have to store one bit per ref
you're checking for each commit.

I played around with that a bit a while ago, and it did seem to work. I
can dig up the patches if you're interested. But one downside is that
one bit per ref per commit adds up if you have a lot of refs. A large
number of those bitfields will be the same, so you could probably get by
with a copy-on-write scheme, but I never implemented that.

Of course somebody may have a more clever algorithm, too. I don't claim
the above is a proof. ;)

-Peff

      reply	other threads:[~2017-09-11 18:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30  9:46 [PATCH] name-rev: change ULONG_MAX to TIME_MAX Michael J Gruber
2017-08-30 20:23 ` Johannes Schindelin
2017-09-06  3:35 ` Junio C Hamano
2017-09-06 11:59   ` Michael J Gruber
2017-09-06 13:35     ` Jeff King
2017-09-07 12:17       ` Michael J Gruber
2017-09-07 14:02         ` [PATCH 0/4] Test name-rev with small stack Michael J Gruber
2017-09-07 14:02           ` [PATCH 1/4] t7004: move limited stack prereq to test-lib Michael J Gruber
2017-09-07 14:02           ` [PATCH 2/4] t6120: test name-rev --all and --stdin Michael J Gruber
2017-09-07 14:02           ` [PATCH 3/4] t6120: clean up state after breaking repo Michael J Gruber
2017-09-07 14:02           ` [PATCH 4/4] t6120: test describe and name-rev with deep repos Michael J Gruber
2017-09-07 14:54           ` [PATCH 0/4] Test name-rev with small stack Jeff King
2017-09-08 12:33             ` Michael J Gruber
2017-09-11 18:08               ` Jeff King [this message]

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=20170911180824.gf6jecxpx7d3d4a7@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@grubix.eu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).