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

Re: git-last-modified(1) slower than git-log(1)?

From
GGusted <gusted@codeberg.org>
Date
Jul 17, 2026, 00:19 UTC
Message-ID
<6491c7e6-9310-4a5e-8ba5-9d3a2e7e3312@codeberg.org>
In-Reply-To
<87v7afffpa.fsf@emacs.iotcl.com>
On 7/16/26 11:26 AM, Toon Claes wrote:
Show 37 quoted lines
> Hi Gusted,
> 
> Thanks for reaching out.
> 
> You're actually not the first to notice this, and I've been aware of
> this.
> 
> The thing is, you're testing the difference on a single file. For us at
> GitLab, it wasn't very useful to optimize that use-case, because usually
> we want to see the last commit for a bunch of files at once.
> So the use-case for git-last-modified(1) for us has been to replace
> (pseudo code):
> 
> $ FILES=$(git ls-tree $COMMIT $PATH)
> $ foreach $FILE in $FILES; do git log -1 $COMMIT -- $FILE; end
> 
> GitLab is batching files 25 at once, and in my benchmarking, it was
> shown git-last-modified(1) is faster:
> 
> $ git last-modified $COMMIT -- <files
> 
> (I did this benchmarking in our Gitaly component to have a real-world
> experience and you can visit the results at:
> https://gitlab.com/gitlab-org/gitaly/-/merge_requests/7999#note_2850505479
> )
> 
> So we left the door open for future improvement, although I never have
> gotten to it. At some point I was trying to chase down when git-log(1)
> was doing differently, but I never figured it out.
> 
> But this email challenged me already. And with some help of AI, I
> managed to work on some improvements. You can expect a patch series
> soon.
> 
> (Right before sending out this mail I noticed Peff sent out some changes
> as well. I'll coordinate how to combine.)
> 
Hi Toon and Jeff,
Thanks for having a look at this!

The use case for Forgejo is the same as Gitlab then, we only use it to get the last-modified of each entry in a directory. Looking a bit closer I missed that in Forgejo's code it's considered the output might not have the answer of all entries, and happily calls it as many time is needed on the 'remaining paths', especially when using gitlab as repository this required a lot of git-log calls.

Looking at the mentioned benchmark, yeah this is where Forgejo's implementation with git-log would fail in terms of performance (seemingly even slower than doing N-1 git-log calls, by using your benchmark numbers). It's somewhere in the minutes :')

Kind Regards Gusted

Previous: Toon ClaesNext: Jeff King
Message 6 of 8 in “git-last-modified(1) slower than git-log(1)?”
  1. GustedJul 14, 2026
  2. Jeff KingJul 16, 2026
  3. Toon ClaesJul 16, 2026
  4. Jeff KingJul 17, 2026
  5. Toon ClaesJul 16, 2026
  6. GustedJul 17, 2026
  7. Jeff KingJul 17, 2026
  8. Toon ClaesJul 17, 2026

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.