threads / discuss / 59542

git log causing hang while browsing upstream linux

Subject: git log causing hang while browsing upstream linux

## tl;dr

9 messages between Apr 4, 2023 and Apr 16, 2023.

replies: 8people: 6as markdown or json

Rohit Ner· Apr 4, 2023, 20:13 UTC · lore

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
1. git clone https://github.com/torvalds/linux.git
2. git checkout master
3. git log --oneline --graph

What did you expect to happen? (Expected behavior) See a graph of onelined commit histories

What happened instead? (Actual behavior) Hang after entering the command

What's different between what you expected and what actually happened? The output is empty and the cursor is stuck. Cursor is unresponsive to any key press other than ^C which leads to an output like below ### OUTPUT START ### ... ~ ~ ~ ~ (END) ### OUTPUT END ### Pressing q key helps get the prompt back.

Anything else you want to add:

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh compiler info: gnuc: 12.2 libc info: glibc: 2.36 $SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks] commit-msg pre-commit prepare-commit-msg

Kristoffer Haugsbakk· Apr 4, 2023, 20:27 UTC · re: Rohit Ner · lore

Re: git log causing hang while browsing upstream linux

On Tue, Apr 4, 2023, at 22:13, Rohit Ner wrote:
Show 7 quoted lines
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
> 1. git clone https://github.com/torvalds/linux.git
> 2. git checkout master
> 3. git log --oneline --graph
Seems like `--graph` is expensive.
FWIW: on my machine:
    $ time git log --oneline --graph | head -1 
    *   76f598ba7d8e Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
    real	0m10.616s
    user	0m9.594s
    sys	0m0.654s
Second attempt is only marginally faster.
-- 
Kristoffer Haugsbakk
Kristoffer Haugsbakk· Apr 4, 2023, 20:50 UTC · re: Kristoffer Haugsbakk · lore

Re: git log causing hang while browsing upstream linux

On Tue, Apr 4, 2023, at 22:27, Kristoffer Haugsbakk wrote:
> FWIW: on my machine:

So my point is: have you given the command a half a minute or so to output the initial lines? Certain `log` invocations can take a long time on repositories with rich histories.

-- 
Kristoffer Haugsbakk
Rohit Ner· Apr 10, 2023, 17:07 UTC · re: Kristoffer Haugsbakk · lore

Re: git log causing hang while browsing upstream linux

I have not given the command more than 10 seconds, shouldn't the intended behaviour be to render the visible subgraph first?

On Wed, Apr 5, 2023 at 2:21 AM Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> wrote:

Show 10 quoted lines
>
> On Tue, Apr 4, 2023, at 22:27, Kristoffer Haugsbakk wrote:
> > FWIW: on my machine:
>
> So my point is: have you given the command a half a minute or so to
> output the initial lines? Certain `log` invocations can take a long time
> on repositories with rich histories.
>
> --
> Kristoffer Haugsbakk
Taylor Blau· Apr 11, 2023, 00:00 UTC · re: Rohit Ner · lore

Re: git log causing hang while browsing upstream linux

On Mon, Apr 10, 2023 at 10:37:15PM +0530, Rohit Ner wrote:
> I have not given the command more than 10 seconds, shouldn't the
> intended behaviour be to render the visible subgraph first?

This is possible with Git's "commit-graph" feature, which you can read about starting here:

		https://devblogs.microsoft.com/devops/supercharging-the-git-commit-graph/

TL;DR: if you run "git commit-graph write" once before running "git log --oneline --graph", you'll get near-instantaneous results.

Thanks, Taylor

Kristoffer Haugsbakk· Apr 11, 2023, 09:45 UTC · re: Taylor Blau · lore

Re: git log causing hang while browsing upstream linux

On Tue, Apr 11, 2023, at 02:00, Taylor Blau wrote:
> TL;DR: if you run "git commit-graph write" once before running "git log
> --oneline --graph", you'll get near-instantaneous results.
Cool! Testing on Linux repo:
Without it:
    $ time git log --oneline --graph | head -1
    *   0d3eb744aed4 Merge tag 'urgent-rcu.2023.04.07a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu
    real	0m11.379s
    user	0m10.655s
    sys	0m0.726s
With it:
    $ time git log --oneline --graph | head -1
    *   0d3eb744aed4 Merge tag 'urgent-rcu.2023.04.07a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu
    real	0m0.032s
    user	0m0.014s
    sys	0m0.023s
Maybe I’m gonna enable `git maintenance` for my repos. :)
-- 
Kristoffer Haugsbakk
SZEDER Gábor· Apr 16, 2023, 07:09 UTC · re: Taylor Blau · lore

Re: git log causing hang while browsing upstream linux

On Mon, Apr 10, 2023 at 08:00:05PM -0400, Taylor Blau wrote:
Show 10 quoted lines
> On Mon, Apr 10, 2023 at 10:37:15PM +0530, Rohit Ner wrote:
> > I have not given the command more than 10 seconds, shouldn't the
> > intended behaviour be to render the visible subgraph first?
> 
> This is possible with Git's "commit-graph" feature, which you can read
> about starting here:
> 
> 		https://devblogs.microsoft.com/devops/supercharging-the-git-commit-graph/
> 
> TL;DR: if you run "git commit-graph write"

Please never recommend 'git commit-graph write' without '--reachable'; scanning all packed objects to find commits to include in the commit-graph is just too inefficient for that.

> once before running "git log
> --oneline --graph", you'll get near-instantaneous results.

The commit-graph has been enabled by default in v2.24.0, released over three years ago. I wonder why Rohit's and/or Kristoffer's repos didn't have it already?!

Kristoffer Haugsbakk· Apr 16, 2023, 12:46 UTC · re: SZEDER Gábor · lore

How to write to the commit graph on clone?

> The commit-graph has been enabled by default in v2.24.0, released over
> three years ago.  I wonder why Rohit's and/or Kristoffer's repos
> didn't have it already?!

I might have done a fresh clone of Linux right before I replied to this email thread, or else it might have just been lying around. (I don’t work on Linux. ;)

I found out that I need to add this to my Git config in order for the commit graph to be updated on `git fetch`, so I added it:

    [fetch]
            writeCommitGraph = true
I was wondering if this would help with cloning, so I did a fresh one:
    $ git clone https://github.com/torvalds/linux/ linux-github-2
    $ cd linux-github-2/
    $ time git log --oneline --graph | head -1
    *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6
    real	0m10.364s
    user	0m9.700s
    sys	0m0.666s
So no.
But doing a `git fetch origin` fixed it:
    $ git fetch origin
    Expanding reachable commits in commit graph: 1171056, done.
    Writing out commit graph in 5 passes: 100% (5855280/5855280), done.
    $ time git log --oneline --graph | head -1
    *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6
    real	0m0.017s
    user	0m0.007s
    sys	0m0.013s
Is there any config for writing to the commit graph on clone?
-- 
Kristoffer Haugsbakk
Ævar Arnfjörð Bjarmason· Apr 16, 2023, 15:24 UTC · re: Kristoffer Haugsbakk · lore

Re: How to write to the commit graph on clone?

On Sun, Apr 16 2023, Kristoffer Haugsbakk wrote:
Show 40 quoted lines
>> The commit-graph has been enabled by default in v2.24.0, released over
>> three years ago.  I wonder why Rohit's and/or Kristoffer's repos
>> didn't have it already?!
>
> I might have done a fresh clone of Linux right before I replied to this
> email thread, or else it might have just been lying around. (I don’t
> work on Linux. ;)
>
> I found out that I need to add this to my Git config in order for the
> commit graph to be updated on `git fetch`, so I added it:
>
>     [fetch]
>             writeCommitGraph = true
>
> I was wondering if this would help with cloning, so I did a fresh one:
>
>     $ git clone https://github.com/torvalds/linux/ linux-github-2
>     $ cd linux-github-2/
>     $ time git log --oneline --graph | head -1
>     *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6
>
>     real	0m10.364s
>     user	0m9.700s
>     sys	0m0.666s
>
> So no.
>
> But doing a `git fetch origin` fixed it:
>
>     $ git fetch origin
>     Expanding reachable commits in commit graph: 1171056, done.
>     Writing out commit graph in 5 passes: 100% (5855280/5855280), done.
>     $ time git log --oneline --graph | head -1
>     *   3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-fix' of git://git.samba.org/sfrench/cifs-2.6
>
>     real	0m0.017s
>     user	0m0.007s
>     sys	0m0.013s
>
> Is there any config for writing to the commit graph on clone?

I don't think there is, but here's a lengthy discussion I started a while ago about having some "on glone gc", which would cover this: https://lore.kernel.org/git/87tvm3go42.fsf@evledraar.gmail.com/

I haven't re-read it just now, but if you're interested that should be a good place to start.

← back to recent threads