Thread (8 messages) 8 messages, 3 authors, 2d ago

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

From: Gusted <hidden>
Date: 2026-07-17 00:19:58


On 7/16/26 11:26 AM, Toon Claes wrote:
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help