lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Slow Commits/Reflog tab

Open gprocopciucnxp opened this issue 2 years ago • 2 comments

Discussed in https://github.com/jesseduffield/lazygit/discussions/2396

Originally posted by gprocopciucnxp January 27, 2023 Hello,

First of all, I would like to say a big thank you to all contributors to this project! It's really helpful and makes the interaction with git much easier and, quicker. I updated the lazygit to the latest released version and observed a significant slowdown of the Commits/Reflog tab during startup. It takes ~15 seconds to be populated for the Linux Kernel project. Here are the steps to be reproduced:

  1. Clone Linux Kernel git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
  2. Go into Linux Kernel repo cd linux
  3. Download and install the latest version of the lazygit
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
tar xf lazygit.tar.gz lazygit
sudo install lazygit /usr/local/bin
  1. Check the version of the newly installed lazygit
test@workstation:~$ lazygit --version
commit=d1a8b05401ccda1e52215203139a252eb3be3b79, build date=2022-11-14T09:22:31Z, build source=binaryRelease, version=0.36.0, os=linux, arch=amd64, git version=2.32.0
  1. Start the lazygit

Observed behavior: It takes ~15 seconds to load the 'Reflog/Commits' view, which is a lot of time.

I took a look into strace output. This takes most of the above-mentioned startup time:

[pid 41661] execve("/usr/bin/git", ["git", "-c", "log.showSignature=false", "log", "HEAD", "--topo-order", "--oneline", "--pretty=format:%H%x00%at%x00%aN"..., "-300", "--abbrev=40"], 0xc00051ba40 /* 57 vars */ <unfinished ...>

The --topo-order parameter seems to be the source of the slowdown. I have tried some other commit ordering rules, but with no success; all of them are slow.

Only the removal or usage of the default order helped in my case. This is my dirty patch which I suppose has to be transformed into a new option. E.g git.log.order: 'default'

diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go
index 40129287..f04939c7 100644
--- a/pkg/commands/git_commands/commit_loader.go
+++ b/pkg/commands/git_commands/commit_loader.go
@@ -427,6 +427,7 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
        config := self.UserConfig.Git.Log

        orderFlag := "--" + config.Order
+       orderFlag = ""
        allFlag := ""
        if opts.All {
                allFlag = " --all"

Regards, Ghennadi

gprocopciucnxp avatar Jan 27 '23 05:01 gprocopciucnxp

I did have the same issue. The best fix I found so far is to actually speed up the git log underneath with:

git commit-graph write

schlac avatar Mar 11 '24 09:03 schlac

I did have the same issue. The best fix I found so far is to actually speed up the git log underneath with:

git commit-graph write

I recommend against doing this manually. Look intogit maintenance start instead, it takes care of this and a bunch of other useful things.

stefanhaller avatar Mar 11 '24 10:03 stefanhaller