git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/4] Test name-rev with small stack

From
Jeff King <peff@peff.net>
Date
Sep 11, 2017, 18:08 UTC
Message-ID
<20170911180824.gf6jecxpx7d3d4a7@sigill.intra.peff.net>
In-Reply-To
<9b3275a2-7b47-9ed8-6f1f-dac999c3b46a@grubix.eu>
On Fri, Sep 08, 2017 at 02:33:35PM +0200, Michael J Gruber wrote:
Show 7 quoted lines
> 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.

Show 5 quoted lines
> 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
Previous: Michael J Gruber
Message 14 of 14 in “name-rev: change ULONG_MAX to TIME_MAX”
  1. name-rev: change ULONG_MAX to TIME_MAXMichael J Gruber, Aug 30, 2017
  2. Johannes SchindelinAug 30, 2017
  3. Junio C HamanoSep 6, 2017
  4. Michael J GruberSep 6, 2017
  5. Jeff KingSep 6, 2017
  6. Michael J GruberSep 7, 2017
  7. 2/4 t6120: test name-rev --all and --stdinMichael J Gruber, Sep 7, 2017
  8. 4/4 t6120: test describe and name-rev with deep reposMichael J Gruber, Sep 7, 2017
  9. 1/4 t7004: move limited stack prereq to test-libMichael J Gruber, Sep 7, 2017
  10. 3/4 t6120: clean up state after breaking repoMichael J Gruber, Sep 7, 2017
  11. 0/4 Test name-rev with small stackMichael J Gruber, Sep 7, 2017
  12. Jeff KingSep 7, 2017
  13. Michael J GruberSep 8, 2017
  14. Jeff KingSep 11, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.