From: Thomas Rast <trast@student.ethz.ch>
To: Junio C Hamano <gitster@pobox.com>
Cc: Michael Haggerty <mhagger@alum.mit.edu>,
Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>,
<git@vger.kernel.org>
Subject: Re: [PATCH v2] rev-list docs: clarify --topo-order description
Date: Fri, 17 Aug 2012 11:50:30 +0200 [thread overview]
Message-ID: <87sjbletjt.fsf@thomas.inf.ethz.ch> (raw)
In-Reply-To: <874no1hnfg.fsf@thomas.inf.ethz.ch> (Thomas Rast's message of "Fri, 17 Aug 2012 11:34:27 +0200")
Thomas Rast <trast@inf.ethz.ch> writes:
> Junio C Hamano <gitster@pobox.com> writes:
>
> The topo order algorithm can be modified to take advantage of
> [generation numbers], in order to provide incremental processing:
>
> Let S be the set of tentative sources
>
> Let U be the set of vertices whose out-edges are no known yet
> (i.e., the set of commits which haven't been loaded yet)
[...]
> while there are any vertices left:
>
> pick any tentative source C from S that we "want to emit"
>
> # Ascertain that no unknown commit (from U or further beyond) can be
> # a descendant of C
> while there is a D in U such that g(D) > g(C):
> load D
> remove D from U
> add the parents of D to U if they were not already loaded
> possibly remove some elements of S if their indegree became nonzero
>
> if C was removed from S:
> continue
>
> remove C from the graph and emit it
By the way, this does bump the runtime of the algorithm a bit, depending
on the data structure used for U. Recall that ordinary topo-sort with a
stack for S (i.e., --topo-order) runs linearly with the number of
vertices.
If we use a priority queue for U, which lets us get at the
highest-generation unknown commits easily, it potentially goes to n log n
if U reaches linear size at some point.
That shouldn't hurt too much of course, since on the one hand it should
rarely actually get that big, and OTOH --date-order has n log n runtime
anyway (using a priority queue for S).
Thanks for challenging me on my "it should work" feeling. It was quite
interesting to actually think it through and write down a workable
algorithm.
--
Thomas Rast
trast@{inf,student}.ethz.ch
next prev parent reply other threads:[~2012-08-17 9:50 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-13 22:21 [PATCH] rev-list docs: clarify --topo-order description Junio C Hamano
2012-08-13 22:46 ` Martin von Zweigbergk
2012-08-13 23:05 ` Junio C Hamano
2012-08-14 5:33 ` Martin von Zweigbergk
2012-08-14 14:54 ` Junio C Hamano
2012-08-14 8:22 ` Michael Haggerty
2012-08-14 8:45 ` Thomas Rast
2012-08-14 14:30 ` Junio C Hamano
2012-08-14 14:51 ` Thomas Rast
2012-08-14 15:47 ` Junio C Hamano
2012-08-15 20:02 ` [PATCH v2] " Junio C Hamano
2012-08-16 6:06 ` Martin von Zweigbergk
2012-08-16 6:20 ` Junio C Hamano
2012-08-16 6:26 ` Junio C Hamano
2012-08-16 8:51 ` Thomas Rast
2012-08-16 10:01 ` Michael Haggerty
2012-08-16 12:00 ` Thomas Rast
2012-08-16 16:10 ` Junio C Hamano
2012-08-17 9:34 ` Thomas Rast
2012-08-17 9:50 ` Thomas Rast [this message]
2012-08-17 17:18 ` Junio C Hamano
2012-08-17 17:37 ` Thomas Rast
2012-08-17 18:11 ` Junio C Hamano
2012-08-17 17:40 ` Junio C Hamano
2012-08-16 16:35 ` Michael Haggerty
2012-08-16 8:42 ` Thomas Rast
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=87sjbletjt.fsf@thomas.inf.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=martin.von.zweigbergk@gmail.com \
--cc=mhagger@alum.mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.