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

libgit2 git_status_list_new is really slow. #28

Open
Stebalien opened this issue Feb 23, 2015 · 9 comments
Open

libgit2 git_status_list_new is really slow. #28

Stebalien opened this issue Feb 23, 2015 · 9 comments
Assignees
Labels
features › git Things to do with Git performance Performance stuff

Comments

@Stebalien
Copy link
Contributor

For me, exa takes ~3 seconds to run on the rust repository and most of this time is spent in libgit2's git_status_list_new function (specifically, it appears that most of this time is spent calculating SHA1 hashes). However, git status --porcelain runs in about .1 seconds. The correct fix would be to fix libgit2 however, in the meantime, you might consider using git directly.

Note git2::Repository::statuses(opts) is a wrapper for libgit2's git_status_list_new function.

@ogham ogham self-assigned this Feb 23, 2015
@ogham
Copy link
Owner

ogham commented Feb 23, 2015

Yeah, I've had reports of the Git functionality being really slow on large Git repositories. I'm looking into what I can do with libgit2 to mitigate this. As you say, it seems to process a lot of SHA1 hashes before it even starts doing anything, and I think that I'm asking it to do a lot more work than I need to.

I'd rather not call Git directly, as it's hard to get it working accurately when you're outside of the repository directory (you have to find the root). If I can't find a way to speed it up in the near future, I'll at least include a --no-git stopgap so you can disable the column on a per-invocation basis.

@ogham ogham added the errors › invalid output exa didn’t crash but was incorrect label Feb 23, 2015
@Stebalien
Copy link
Contributor Author

Asking libgit2 to update the index shaves about a half of a second off of subsequent runs but none of the other options helped (except passing StatusOptions::new().show(ShowOptions::Index) but that also gets rid of most of the useful information so it's a non-starter). I'd also rather not call git directly but I don't know of a better fix. You could find the git root using libgit2 and then operate on it using the git command.

@lilydjwg
Copy link
Contributor

lilydjwg commented Aug 3, 2015

exa takes quite a few seconds in my rustc repository, even without the --git option. I don't understand why exa tries to read git information when it doesn't show them.

@ogham
Copy link
Owner

ogham commented Aug 3, 2015

It shouldn't do that! Let me test this.

@ogham
Copy link
Owner

ogham commented Aug 3, 2015

Confirmed - that's definitely wrong!

ogham added a commit that referenced this issue Aug 3, 2015
This is very slow (see #28) at the moment, so there's an option to switch off repo discovery. However, they were still always being queried. Now, if there's no Git option in the flags, it won't try to discover a repo.
@ogham
Copy link
Owner

ogham commented Aug 3, 2015

d547c3f should fix it. Thanks for noticing the problem!

@ogham ogham added this to the v1.0.0 milestone Sep 2, 2015
@ogham ogham added the features › git Things to do with Git label Sep 2, 2015
@ogham
Copy link
Owner

ogham commented Sep 2, 2017

I think this might be related: libgit2/libgit2#4230

@dickshaydle
Copy link

I think the problem is that it searches in all subfolders, although only the current folder is needed.

You can see that if you take any larger folder that is not yet a git repo, make it git repo with
git init
and than look at the strace output
strace -f exa -l --git

The -f for strace means, it follow all threads / forks of that process.

@ariasuni
Copy link
Collaborator

ariasuni commented May 19, 2021

exa is getting all the statuses of every file though the libgit2 and store them so it only had to query them once. Now I guess we could try to ask just about the file we find if it’s faster (or use that strategy only when we don’t recurse or something like that), or just parse the output of git like many other projects did.

Anyway, it’s a non-trivial amount of work for something that already works, so any help is welcome.

@ariasuni ariasuni added performance Performance stuff and removed errors › invalid output exa didn’t crash but was incorrect labels Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
features › git Things to do with Git performance Performance stuff
Projects
None yet
Development

No branches or pull requests

5 participants