zsh-workers
 help / color / mirror / code / Atom feed
* Setting cdablevars adds 10-15s to run time for non existing command
@ 2021-03-18 23:42 Experts Ravioli
  2021-03-23  2:55 ` Bart Schaefer
  2021-03-23 12:40 ` Stephane Chazelas
  0 siblings, 2 replies; 3+ messages in thread
From: Experts Ravioli @ 2021-03-18 23:42 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]

Hey everyone.

If I use `setopt cdablevars` in my .zshrc and then I try to run a
`insert_random_command_name_here` (which does not exist) the prompt returns
after 10-15s.
This happens with Alacritty, Gnome Terminal and Tilix. Does not happen if I
switch to bash. Does not happen if I comment out `cdablevars`.

When I say run time, I mean actual time on the clock. If I run the command
through `time insert_random_command_name_here` it takes the same amount,
but the output is:

```
% time insert_random_command_name_here
zsh: command not found: insert_random_command_name_here
insert_random_command_name_here  0,00s user 0,00s system 79% cpu 0,002 total
```

Here some more info:


```
% uname -a
Linux ### 5.10.24-051024-generic #202103171801 SMP Wed Mar 17 18:42:04 UTC
2021 x86_64 x86_64 x86_64 GNU/Linux

% lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal

% alacritty --version
alacritty 0.7.2

% zsh --version
zsh 5.8 (x86_64-ubuntu-linux-gnu)
```

```
% cat .zshrc
#!/usr/bin/zsh
#disable ctrl-s ctrl-q
stty -ixon

# color
autoload -U colors
colors

# history
setopt hist_ignore_all_dups inc_append_history extended_history
HISTFILE="$ZDOTDIR/history"
HISTSIZE=8192
SAVEHIST=16384

# keybindings
bindkey -v
bindkey "^B" beginning-of-line
bindkey "^R" history-incremental-search-backward

# remap Insert to Print Screen
xmodmap -e "keycode 118 = Print"

# options
# awesome cd movements from zshkit
setopt autocd autopushd pushdminus pushdsilent pushdtohome *cdablevars*
DIRSTACKSIZE=5
```

```
% cat .zshenv
#!/usr/bin/zsh

# XDG

export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$XDG_CONFIG_HOME/local/share"
export XDG_CACHE_HOME="$XDG_CONFIG_HOME/cache"

# zsh

export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
```

Does anyone have any idea?

Thanks a bunch!

[-- Attachment #2: Type: text/html, Size: 2601 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Setting cdablevars adds 10-15s to run time for non existing command
  2021-03-18 23:42 Setting cdablevars adds 10-15s to run time for non existing command Experts Ravioli
@ 2021-03-23  2:55 ` Bart Schaefer
  2021-03-23 12:40 ` Stephane Chazelas
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2021-03-23  2:55 UTC (permalink / raw)
  To: Experts Ravioli; +Cc: zsh-workers

Meant to reply to this a while ago but it fell down the stack.

On Thu, Mar 18, 2021 at 4:42 PM Experts Ravioli
<experts.ravioli@gmail.com> wrote:
>
> If I use `setopt cdablevars` in my .zshrc and then I try to run a `insert_random_command_name_here` (which does not exist) the prompt returns after 10-15s.
[...]
> setopt autocd autopushd pushdminus pushdsilent pushdtohome cdablevars
>
> Does anyone have any idea?

It's not (just) cdablevars, it's autocd.  When you have both of those
set, zsh attempts to interpret 'insert_random_command_name_here' as a
possible reference to a directory to which to (auto)cd, which in turn
results in a check for whether it should create parameter table
entries for any location that might be related to that name.  If your
$path and $cdpath contain either a lot of directories or some
potentially-slow remote mount points, that operation could be very
time consuming.  If it succeeded, the result would be cached and be
fast the next time, but failure is always slow.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Setting cdablevars adds 10-15s to run time for non existing command
  2021-03-18 23:42 Setting cdablevars adds 10-15s to run time for non existing command Experts Ravioli
  2021-03-23  2:55 ` Bart Schaefer
@ 2021-03-23 12:40 ` Stephane Chazelas
  1 sibling, 0 replies; 3+ messages in thread
From: Stephane Chazelas @ 2021-03-23 12:40 UTC (permalink / raw)
  To: Experts Ravioli; +Cc: zsh-workers

2021-03-18 23:42:30 +0000, Experts Ravioli:
[...]
> If I use `setopt cdablevars` in my .zshrc and then I try to run a
> `insert_random_command_name_here` (which does not exist) the prompt returns
> after 10-15s.
[...]

See also:

https://unix.stackexchange.com/questions/606118/zsh-slow-doing-eval-with-path

There, I did say (among other things I invite you to read):

} I would personally stay clear of that cdablevars option as it's
} bound to give you bad surprises one day or another. Without it,
} you can always do cd ~user or cd ~var, and I find it much better
} to request it explicitly when you do want to cd into something
} other than the directory given as argument.
} 
} That cdablevars was already in the very first version of zsh
} from 1990, inspired by tcsh that does that by default. It
} predates the expansion of ~var. cdablevars should be considered
} as a historical artefact IMO.

-- 
Stephane


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-23 12:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 23:42 Setting cdablevars adds 10-15s to run time for non existing command Experts Ravioli
2021-03-23  2:55 ` Bart Schaefer
2021-03-23 12:40 ` Stephane Chazelas

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).