Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files panel is empty when (many) new/changed files exist #3798

Closed
vlcinsky opened this issue Aug 5, 2024 · 3 comments · Fixed by #3919
Closed

Files panel is empty when (many) new/changed files exist #3798

vlcinsky opened this issue Aug 5, 2024 · 3 comments · Fixed by #3919
Labels
bug Something isn't working

Comments

@vlcinsky
Copy link

vlcinsky commented Aug 5, 2024

Describe the bug
While git status shows that changed/new files exist, lazygit panel "Files" panel is empty.

This happens when number of new/changed files is really large (e.g. 90 thousands) - lazygit is aware of their existence but it takes 9 seconds (on my MacBook Pro M1) until anything is printed into Files panel. Until then, user feels like lazygit ignores the changes as there is no sign, lazygit is still trying to show somehting.

To Reproduce
Steps to reproduce the behavior:

  1. Prepare new repository with simple initial commit:
$ mkdir manylazyfiles
$ cd manylazyfiles
$ touch README.md
$ git init
Initialized empty Git repository in manylazyfiles/.git/
$ git add README.md
$ git commit -m "Initial commit"
[master (root-commit) 45d7d58] Initial commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
  1. Prepare a folder with 90000 files
mkdir data
seq 90000 |xargs -I {} touch data/file-{}.txt
  1. Check git status:
$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
	data/

nothing added to commit but untracked files present (use "git add" to track)
  1. Open lazygit and watch content of the Files panel
lazygit

The panel is empty and lazygit seems ignoring the newly created files until like 9 seconds and then the files are shown properly.

Typical developer will give up after few seconds closing lazygit with unfair remark "ignorant".

Expected behavior
lazygit would print initially "Reading files..." into Files panel and would then replace it with whatever final result would finally get there.

This could happen always or (optimized variant) only if the content of the panel is not populated within a second.

Screenshots
Initial presentation with empty Files (during rendering large number of new items):
obrazek

And after cca 9 seconds the files are finally shown:
obrazek

Version info:

$ lazygit --version
commit=, build date=, build source=homebrew, version=0.43.1, os=darwin, arch=arm64, git version=2.45.2
$ git --version
git version 2.45.2
@vlcinsky vlcinsky added the bug Something isn't working label Aug 5, 2024
@stefanhaller
Copy link
Collaborator

lazygit would print initially "Reading files..." into Files panel and would then replace it with whatever final result would finally get there.

Before we do that, we should see if it's possible to optimize the code so that it doesn't take so long. There's really no reason why it should take several seconds to populate the files panel with a few thousand files.

A cursory profiling shows that almost all the time is spent inside the BuildTreeFromFiles function, so it looks like we only need to speed up that function. Looking at that function (with squinted eyes), it does look like it has quadratic behavior when there are lots of files in the same directory, but I don't have time to investigate this further right now. Do you feel like looking into this?

@parthokunda
Copy link

Can I take a loot at it?

@vlcinsky
Copy link
Author

Great.
Guys @stefanhaller , @parthokunda you did excellent job.

In my testing repository "manylazyfiles" where it took 9 seconds it now takes fraction of a second (I would say 0.3).

Me and my colleague also enjoy your approach - simply optimizing the process without introducing complexities with "loading ...".

Well done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants