pkgx: bug: pkgx's git is slow

While making my first steps with pkgx, I found that my shell became really slow at giving back the prompt. Running zsh -x showed me that it was caused by Git. I was about to start a contribution for the pantry and just executed a dev command. I realized it installed the git package from pkgx and that my shell was not using the system Git, but the one from pkgx.

For example, git branch went from taking about ~3ms to more than 1s!

Here’s a reproduction link: https://github.com/aslafy-z/pkgx-reproduce-slow-git

Do you have any idea where this issue might be coming from?

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 36 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Is it possible to disable pkgx’s custom git? I’m having http://starship.rs in my shell which displays the git status and branch in the prompt. Usually its super fast, but when running dev my shell gets super slow and starship timings shows that its because of the git commands.

@jhheider I opened a PR here: https://github.com/pkgxdev/pantry/pull/4121

This is quite brittle, as it’s just a matter of time before git adds arguments which will require a change here. I would personally like to disable git-scm.org globally for when using dev because of this, like I mentioned above.

Is there any way to globally configure pkgx never to use git-scm.org?

This has been requested before. I’m not yet sure how to handle the configuration. We add git so the user doesn’t need the Xcode Command Line Tools to dev which is a feature, though in cases where the user doesn’t want that it is reasonable we allow such opt outs.

you beat me to it, @fredrikaverpil . glad to be of assistance.

this rebuild got it. interestingly, @mxcl, pkgx +git@latest didn’t seem to do it, but rm -rf ... did.

it’s possible CI didn’t trigger the build, since I didn’t change the package.yml. sloppy on my part, if so. i’ll trigger a rebuild now.

Thanks all.

pkgx needs to be way faster in general. We intend to make a cache for pantry reads which should reduce as much as deno makes possible. Eventually we would like to rewrite in rust, but I have too many TODO items before that.

The cache should make it so even this situation would have been fast, though I’m glad it wasn’t since we caught the bug.

Need to use set -u more often I think.

what are friday nights for? 😉

So, 500ms from pkgx git to the shim, and 500ms for the extra check with pkgx --provider. Two pkgx startups for git branch, 500ms each. A single one for git --version.

Git is often used in shell prompts like it is in the default codespace setup. It is really slow to work with.

I’ve read in #341 the plan was to rewrite the cli in rust after the 1.0 release. Is it still something you want to do?

https://github.com/pkgxdev/pantry/actions/runs/6438659399

after this, it should only be slow when searching for external commands it doesn’t ship.