-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update datafile in background for speed #191
Comments
interested in this too. I removed |
Glad I'm not the only one! Did you try my fix? (I modified this line, but I believe you could also set |
That looks about right. Does it work? Allen
|
No. it remains lagging my prompt. |
I actually have
Try that? |
then i get: but afterwards, it kind of works, but it is laggy all the same. |
Interesting. Well... mine definitely runs faster now. The difference seems to be about 0.1 seconds: $ time _z --add /cygdrive/c/Users/guogu_000
real 0m0.103s
user 0m0.030s
sys 0m0.060s
$ time (_z --add /cygdrive/c/Users/guogu_000 &)
real 0m0.006s
user 0m0.000s
sys 0m0.000s |
hum are you under cygwin? |
Yeah, but that shouldn't make a difference because it's still Bash. |
I'm in zsh on osx. |
are you folks playing with this change seeing:
not sure how much i really care about accurate counts, but also i don't care a lot about prompt speed - the speed's never mattered to me when i'm actually working. dangling temp files are more irritating and I don't want them getting more common. |
@ninrod: I believe you'll want to edit this line to get it to work in zsh. @rupa: Hey, thanks for chiming in. (BTW, I really appreciate this project!) To answer your questions:
I agree the speed difference isn't that noticeable. (Although I imagine it's worse on Cygwin than Linux/Mac.) But if there aren't any negative side effects, I think it's a worthwhile improvement. |
Hi @rupa. Well I do care for prompt speed. Without your plugin, my prompt displays as fast as if I had invoked zsh with Now, why must |
Sorry, @rupa, but the difference with and without z in my configuration is very noticeable. I reported this issue a while ago in another source of slowness of my configuration, zsh-autosuggestions: zsh-users/zsh-autosuggestions#136 (comment) Unfortunately, both autosuggestions and z are very important in my daily workflow (especially z, can't live without it). If you just cd across your directories, you may not even notice the delay. However, if you start using MidnightCommander, things get horribly slow. This is maybe due to the fact that MC sends cd command to the underlying shell character by character. I created an issue about that: https://github.com/MidnightCommander/mc/issues/101. I have little hopes this will ever be fixed on their side, though. I also tried hacking MC and surrounded the cd command with zsh's bracketed paste magic to avoid triggering zsh hooks: balta2ar/mc@f17ebb8. It didn't really help. Maybe I'm missing something. Besides of the suggested fix (which I haven't tried yet, but I will), would you be willing to consider asyncronous extension similar to this pull request, @rupa? zsh-users/zsh-autosuggestions#134 |
I've pushed an
|
I've just noticed that suggested change is for bash only. I did the same change in the corresponding zsh if branch above (two places). I've finally managed to conduct an experiment and obtain actual numbers. Maybe this is not really strict and rigorous, but it visualizes the difference. First, I created a nested directory structure (110 dirs) with this code: $ for n in $(seq 110); do DN="${DN}/notsolongdirnametotestnested_$n"; done; mkdir -p "./${DN}" Next I wrote an automation script that runs mc with #!/bin/bash
# To find out the window id use this command:
# $ xdotool selectwindow
WINDOW_ID=$1
echo "Starting test"
xdotool type --window $WINDOW_ID "time mc"
xdotool key --window $WINDOW_ID Return
# Without this keys that follow are not processed correctly
sleep 1
COMMAND=""
for i in $(seq 30); do
COMMAND="$COMMAND Down Return"
done
xdotool key --window $WINDOW_ID $COMMAND ctrl+o
xdotool type --window $WINDOW_ID "exit"
xdotool key --window $WINDOW_ID Return
echo "Test has been finished" Next I ran 5 different set ups 5 times each. Each setup was run in a new terminal tab. In setups I tried different combinations of zsh-autosuggestions and z. Setups are: no_z_no_zus — z and zsh-autosuggestions are disabled
As you can see from only_z_async vs only_z_sync it's 4.4 vs 4.9 (I don't know why only_z_async is faster than no_z_no_zus). Unfortunately, in my configuration zus shadows z to a very big extent, but I still think it's worth it. No new ~/.z.XXXX garbage appeared after these tests. |
@balta2ar woops - can you post the changes you made for zsh support? I'm not great at zsh stuff. |
So almost half a second difference from zsync to noz_nozus. seems about what I get from my end. |
@rupa The idea of changes is exactly the same: offload diff --git a/z.sh b/z.sh
index 197c536..b9638b5 100644
--- a/z.sh
+++ b/z.sh
@@ -216,11 +216,11 @@ if type compctl >/dev/null 2>&1; then
# populate directory list, avoid clobbering any other precmds.
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
_z_precmd() {
- _z --add "${PWD:a}"
+ (_z --add "${PWD:a}" &)
}
else
_z_precmd() {
- _z --add "${PWD:A}"
+ (_z --add "${PWD:A}" &)
}
fi
[[ -n "${precmd_functions[(r)_z_precmd]}" ]] || { @ninrod Are you sure? The difference that I have demonstrated is a difference of cumulative traversal of 30 directories in a row conducted specifically for the experiment to amplify the effect. That's absolutely unrealistic case. What's your set up? Please don't get me wrong, I'm not denying your delays, — I have them too, — I just I don't want to mislead anyone comparing apples to oranges. |
Yeah: 500/30 = 16ms. i get something like 30-50ms delta difference just listing directories with rupa/z turned on. but my setup is heavier. I'll probably have to make a more correct benchmark like yours though. |
@rupa. please protect I've actually defined a function called So instead of using plain |
good point. done. |
Thanks @rupa. but maybe that is not as simple as that? I'm in zsh and I'm not getting core dumped anymore, but I'm getting this after your last commit: ~ ➜ cd code
_z:175: command not found: builtin cd
~ ➜ builtin cd code
code ➜ here's the full function I'm using: cd () {
if [[ -z $1 ]]; then
# $1 is empty. go home
builtin cd ~
elif [[ $1 == '-' ]]; then
# $1 == '-': switch to last visited dir
builtin cd - > /dev/null
elif [[ $1 == '..' ]]; then
builtin cd ..
elif [[ $1 =~ '\+[0-9]{1,2}' ]]; then
# $1: `cd +8`, `cd +10`, cherry pick auto_pushd stack
builtin cd $1 > /dev/null
elif command -v z > /dev/null; then
# careful now. z should use a `builtin cd`. If not we're screwed with an infinite loop.
z $1
else
# rupa/z is not available, use normal cd
builtin cd $1
fi
} |
I think you're missing an something like |
It's this BS http://zsh.sourceforge.net/FAQ/zshfaq03.html (first question) not gonna use eval, luckily I can fix it by removing some uselessly clever nonsense. |
nice one @rupa. so what happens when user has never ever had a steps to reproduce: I've deleted
|
Checked out the |
merged into master. sorry I waited so long, slow and steady :) |
Cool, thanks! |
The default
$PROMPT_COMMAND
isFor me (on Cygwin, Windows 8.1), the default configuration makes it so that if I hold down the Enter key in Bash, the prompts start to lag behind. Overall, the prompt feels slow.
So I changed it to
This seems to mostly fix the issue. The z datafile is updated in the background, silently.
Is there any harm in doing this or reason why this isn't the default?
The text was updated successfully, but these errors were encountered: