-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
exponentially slow when run source .zshrc
several times
#625
Labels
Comments
When you `source zsh-syntax-highlighting.zsh`, the widget wrappers are installed on top of whatever plugins you activated previously. If you activate (source) z-sy-h twice, the wrappers will be installed twice. This was intentionally implemented this way to allow you to do —
source z-sy-h
source some-other-plugin
source z-sy-h
— and still have correct syntax highlighting.
Therefore, _some_ slowness in this use-case is expected. Workarounds include:
- Source z-sy-h just once, at the end, as recommended in the docs.
- Implement your own guard preventing z-sy-h from being sourced multiple times if it's already activated.
- Try the feature/redrawhook branch (see issue #245)
- Use `exec zsh` instead of re-sourcing .zshrc
Your data shows a roughly quadratic dependence of runtime on number of iterations. I would have expected the dependence to be linear. This might be an interesting issue to dig into — if it can be reproduced without omz.
… I use ZSH with a few plugins including zsh-syntax-highlighting,
I sometimes run `source ~/.zshrc` several times, for example when I
edit the prompt theme (in oh-my-zsh).
First time I source, it takes approximately 0.14 seconds, so it's not
so slow,
but if I run it 10 times on the same shell, it takes 0.26 seconds
20 times, 1.31 seconds
30 times, 10.89 seconds
40 times, 40.61 seconds
50 times, 111.55 seconds (and I didn't tried more).
.
The time does not increases if I use only other scripts (I use git, z,
zsh-autosuggestion),
and time increases (twice faster but increases the same way) if I use
only zsh-syntax-highlighting and no other plugin.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#625?email_source=notifications&email_token=AAQK5UAT7R7XCK3RA5S5LVLP6QWPPA5CNFSM4H7CB7B2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G6AN2UQ>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAQK5UFGOONU42QHA3MYHMDP6QWPPANCNFSM4H7CB7BQ>.
|
danielshahaf
changed the title
exponantialy slow when run
exponentially slow when run Mar 17, 2020
source .zshrc
several timessource .zshrc
several times
|
Thanks for following up. In the meantime redrawhook has been merged, which should independently address the issue. |
By the way, if anyone wants to fix the issue for pre-redrawhook zsh, look into `_zsh_highlight_bind_widgets` and its callees and make sure that if z-sy-h is registered multiple times, then all but one of the copies do no work. (Beware of causing a bottomless recursion, where a widget wraps itself, possibly through intermediate wrappers by other plugins; IIRC, that's what the unique $prefix values are for.) E.g., checking $funcstack in `_zsh_highlight_call_widget` might do the trick.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use ZSH with a few plugins including zsh-syntax-highlighting,
I sometimes run
source ~/.zshrc
several times, for example when I edit the prompt theme (in oh-my-zsh).First time I source, it takes approximately 0.14 seconds, so it's not so slow,
but if I run it 10 times on the same shell, it takes 0.26 seconds
20 times, 1.31 seconds
30 times, 10.89 seconds
40 times, 40.61 seconds
50 times, 111.55 seconds (and I didn't tried more).
.
The time does not increases if I use only other scripts (I use git, z, zsh-autosuggestion),
and time increases (twice faster but increases the same way) if I use only zsh-syntax-highlighting and no other plugin.
The text was updated successfully, but these errors were encountered: