jesseduffield / jesseduffield/lazygit

Slow Commits/Reflog tab

Open
#2,397 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

### 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
```bash
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
```
4. Check the version of the newly installed lazygit
```bash
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
```
5. 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:
```bash
[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 */
```

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
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.