Subject: Re: [RFC PATCH 0/5] line-log: towards a more responsive, incremental 'git log -L'

From: SZEDER Gábor <[email-masked]>
Date: Mon, 19 Aug 2019 15:03:23 +0200

On Mon, Aug 19, 2019 at 08:00:11AM -0400, Derrick Stolee wrote:
> On 8/18/2019 2:27 PM, SZEDER Gábor wrote:
> > Line-level log performs a preprocessing step in
> > prepare_revision_walk(), during which it filters and rewrites history
> > to keep only commits modifying the given line range.  This
> > preprocessing causes significant delay before the first commit is
> > shown, wastes CPU time when the user asks only for a few commits, and
> > does parent rewriting with no way to turn it off.
> > 
> > This patch series addresses these issues by integrating line-level log
> > filtering into the revision walking machinery and making it work
> > together with generation number-based topo-ordering (though for now
> > only in the case when the user doesn't explicitly asks for parent
> > rewriting, which is probably the common case).
> > 
> > The first two patches are quite straightforward (and arguably somewhat
> > unrelated), but the rest deals with history traversal and parent
> > rewriting, which I don't usually do, hence the RFC.
> 
> Hi Szeder,
> 
> Thanks for sending this series! I'm particularly excited about it
> because we recently got a bug report from a user in the Windows OS
> repo about "git log -L" being very slow. I put it on the backlog [1]
> but haven't had time to investigate it myself. After we are done
> updating to v2.23.0 [2], I'll have time to test your changes on
> the Windows repo. I anticipate your change to provide a massive
> boost.

Well, it depends on what you mean by "boost"...  As discussed in patch
4's commit message, this series doesn't really optimizes much, and the
total amount of work to be done remains the same, except that 'git log
-L... -<N>' will be able to return early.  So when you benchmark it
with e.g. 'time git log -L... >/dev/null', then you won't see much
difference, as it will still take just about as looooong as before,
apart from the faster generation numbers-based topo-ordering.  (But I
have a few WIP patches waiting to be cleaned up that might bring about
3-4x speedup in general.)

In the meantime, until these changes trickle into a Git release, for a
faster line-level log I would recommend to:

  - Limit the revision range up front, i.e.:

      git log -L... ^a-not-too-old-version

    because this can greatly reduce the amount of commits that that
    expensive preprocessing step has to churn through.

  - Use '--no-renames'.  Although it won't follow the evolution of the
    line range over file renames, this might be an acceptable
    compromise.  (this is what those WIP patches are focusing on)

  - Or both.