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

Re: [perf] git log --follow seems slow

From
Jeff King <peff@peff.net>
Date
Jun 26, 2025, 18:52 UTC
Message-ID
<20250626185216.GB17172@coredump.intra.peff.net>
In-Reply-To
<CADYQcGoAN8bW3SVEdqPLJAMQbicbo6wQW_nNa_uYkXMouxO=Ng@mail.gmail.com>
On Wed, Jun 25, 2025 at 12:44:16PM -0400, Kai Koponen wrote:
> - --follow is not taking advantage of the commit graph (seems likely
> as --follow seems equally slow with core.commitGraph off)

It's mostly this. History pruning is disabled with --follow, since the path of interest may change as we traverse through history. And the use of commit graph changed-path bloom filters is tied to the pruning code. So this hits you two-fold:

  1. For each commit we visit, we actually do a tree diff to see if it
     touched that path (leaving aside rename detection, we still have to
     open the trees down to the path of interest).
  2. We don't prune side-branches of history, so we are visiting more
     commits. Normally when we see a merge of two branches, when one
     parent matches the merge result and the other does not, we know
     that nothing interesting happened on the side branch. So we do not
     traverse those commits at all. But with pruning disabled, that no
     longer happens.

These limitations are mostly due to the hacky way that --follow is bolted on to the traversal machinery. The "right" way for --follow to work is to keep a unique pathspec (and bloom filter) for each line of commits, passing it down as we walk backwards through history (and modifying it when we see a rename).

It's probably possible to bolt bloom-filter checks onto the existing --follow feature, but it would probably involve a lot of special casing.

-Peff
Previous: Kai Koponen
Message 2 of 2 in “[perf] git log --follow seems slow”
  1. Kai KoponenJun 25, 2025
  2. Jeff KingJun 26, 2025

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.