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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use zsh-async to speed-up rendering the prompt #307

Closed
maximbaz opened this issue Jan 12, 2018 · 14 comments
Closed

Use zsh-async to speed-up rendering the prompt #307

maximbaz opened this issue Jan 12, 2018 · 14 comments
Labels
help-wanted We need help to resolve this issue or PR. proposal An issue (rarely PR) for feature-requests, ideas, etc
Milestone

Comments

@maximbaz
Copy link
Contributor

This has been mentioned in #200 as optional, but wasn't implemented, thus creating a tracking ticket that I can subscribe to 馃檪


Let's use zsh-async to speed-up rendering the prompt. My personal favorite is the git_status section (because I saw pure theme do that), but I'm sure many other sections will benefit from this too.

/cc @sei40kr

@denysdovhan denysdovhan added help-wanted We need help to resolve this issue or PR. proposal An issue (rarely PR) for feature-requests, ideas, etc labels Jan 12, 2018
@denysdovhan
Copy link
Member

Would be great to make this happened. I've been working on this. This was too hard to implement, so we've decided to release 3.0 without async rendering. Possibly, we can render all of the sections asynchronously by default (and also provide API for rendering section synchronously if needed).

Any help on this appreciated 馃檹馃徎

@maximbaz maximbaz mentioned this issue Jan 13, 2018
Merged
@belak
Copy link
Contributor

belak commented Jan 14, 2018

I would almost recommend against zsh-async without a fallback, as it causes random issues on systems where zpty doesn't work properly (cygwin sorin-ionescu/prezto#1493 and Windows Subsystem for Linux sorin-ionescu/prezto#1523 are the two I know of). Maybe pure handles it differently - I'll have to check on that.

@maximbaz
Copy link
Contributor Author

Thanks for the insight, definitely something to consider 馃憤

I've just tried out pure theme out of curiosity, async git status is a very very cool experience! You can even make an artificial delay to git to amplify the difference:

# which git
/usr/bin/git
# cd /usr/bin
# mv git g
# echo '#!/usr/bin/env sh\n\nsleep 1\n/usr/bin/g "$@"' > git
# chmod +x git
...
# rm git
# mv g git

The difference is enormous, while spaceship is lagging as hell, pure is still instant, git status icons are slowly being rendered but that doesn't block me from changing directories, typing commands, etc.

Of course in real life the difference is not that big (unless you have some really big git repositories), but the improvement would not be negligible.

@belak
Copy link
Contributor

belak commented Jan 15, 2018

It is also possible to use some form of async without using zsh-async.

Pre-async we did something like this: https://github.com/sorin-ionescu/prezto/blob/9f1a41de9015e89c5553289173e2e1a7e5a0b35d/modules/prompt/functions/prompt_sorin_setup (Note that this approach has a number of downsides - specifically, we didn't do a good job of sanitizing the data, though it should be possible to use a similar approach without introducing vulnerabilities)

This is what it looks like post-async: https://github.com/sorin-ionescu/prezto/blob/ad79f78fbe143e38be421733713e562eccca018b/modules/prompt/functions/prompt_sorin_setup

@denysdovhan
Copy link
Member

spaceship is lagging as hell,

馃槥馃様馃檨

That's why I'm interested in making Spaceship async. Definitely, we should define a new roadmap for 4.0 to make section's rendering asynchronous.

@sei40kr
Copy link

sei40kr commented Jan 16, 2018

I have not so much time too, so it was difficult for me to implement it, sorry.

I created a PR including async jobs using mafredri/zsh-async, but it's still very WIP.
#315

Perhaps it's necessary to change the way to render sections, to render them partially.

@sei40kr
Copy link

sei40kr commented Jan 17, 2018

These are what we need to implement.

  • Update installer to install zsh-async.
  • New prompt rendering (gets section info from global vars instead of running commands and just show them)
  • Manage cache (most of previous sections are reusable on same directory unless user command handles Git)
  • Manage jobs (currently force to flush all jobs on preexec, but it doesn't need to be terminated unless it conflicts with user commands)

@denysdovhan
Copy link
Member

@sei40kr any updates on this?

@willgriffiths
Copy link

Let me know if you need a beta tester. :)

@maximbaz
Copy link
Contributor Author

maximbaz commented Jun 9, 2018

@cyrinux was a beta tester for my own implementation of async spaceship, right now there are no more known bugs so I consider it pretty stable. I made async only those sections that I personally use, but the framework is in place so it's trivial to convert more sections. Feel free to try it out if you are interested, but keep in mind that this is my fork that is made only for me, so it has breaking changes comparing to upstream (I listed them on top of the README).

If you want to convert more sections, here's how to do this and I will accept the PRs, because sooner or later I hope we will integrate the async implementation back into the original project.

@cyrinux
Copy link

cyrinux commented Jun 9, 2018

Hi,
I confirm async implementation of @maximbaz is very cool and with no bug for me right now ;)

@borekb
Copy link

borekb commented Jul 6, 2018

I'm fighting async prompt on Windows / MSYS2 right now so wanted to post a nice link that I found related to this: https://github.com/agkozak/agkozak-zsh-theme#asynchronous-methods.

Note that I'm not a user of Spaceship, this just came up in Google results. (I'm keeping an eye on Spaceship long-term though ;) )

@borekb
Copy link

borekb commented Jul 6, 2018

Probably a better link: mafredri/zsh-async#26

@denysdovhan
Copy link
Member

Resolved by #1056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted We need help to resolve this issue or PR. proposal An issue (rarely PR) for feature-requests, ideas, etc
Development

No branches or pull requests

8 participants