Live data from Hacker News

Bringing down my ZSH load times from ~3.1s to ~230ms

iam.mt

11–20 of 27 posts

Re: Bringing down my ZSH load times from ~3.1s to ~230ms

#11

Earlier quoted context omitted.

I haven't had any issues with `fnm` so far. It's been fast and I like how it prompts you to install a missing node version as soon as you jump into a directory with a `.nvmrc` file.

Mise does similar, but for a while suite of tools instead of just nodejs.

Will check it out, thanks!

Re: Bringing down my ZSH load times from ~3.1s to ~230ms

#13
My mini-story: I'd switched to zimfw which does a ton of caching, precompiling. It benches very well versus other zsh frameworks. But something was still taking almost a second for me, every time. https://github.com/zimfw/zimfw

zprof helped me and the LLM profile and we found it was one plugin, which wasn't really intended specifically for zim. Fixed that! https://github.com/lipov3cz3k/zsh-uv/issues/2

Man it feels so good having shells just open so lightning fast.

Re: Bringing down my ZSH load times from ~3.1s to ~230ms

#15
- none of your blog links work https://iam.mt/blog-changes/

- also you should put a list of all your article. (titles only) on some page called /archive or something

- i really dont want to scroll 5000 pages to see the last 20 articles you wrote

- just a suggestion from a ui / ux perspective

Re: Bringing down my ZSH load times from ~3.1s to ~230ms

#16

- none of your blog links work https://iam.mt/blog-changes/ - also you should put a list of all your article. (titles only) on some page called /archive or something - i really dont want to scroll 5000 pages to see the last 20 articles you wrote - just a suggestion from a ui / ux perspective

will add a page, thanks for the suggestion.

Re: Bringing down my ZSH load times from ~3.1s to ~230ms

#17
Even the final starting time for zsh from TFA is quite bad.

On a 6-year old desktop PC with a Ryzen CPU, an interactive zsh starts in 20 ms and a login zsh starts in 60 ms.

The configuration file for the interactive zsh, i.e. "~/.zshrc", has 75 lines and it configures completions (in the default manner added to ~/.zshrc by compinstall), binds some keys, sets umask and some shell options and defines a bunch of environment variables (including the prompt) and of command aliases.

I do not see what else would be needed, which could increase the starting time.

My login zsh takes 40 ms longer because I do not use a GUI login, but the classic CLI login, so the login zsh checks if a GUI desktop session is running and if not it starts the session (obviously, the 60 ms login zsh starting time is for when the GUI session is already running).

Re: Bringing down my ZSH load times from ~3.1s to ~230ms

#18
I have a complex fish shell configuration with ~100 autoloaded functions and about 180 lines across config.fish and a dozen conf.d/ files.

On my system, hyperfine says fish loads in about 85ms:

  Benchmark 1: fish -il -c exit
    Time (mean ± σ):      85.0 ms ±   3.3 ms    [User: 50.1 ms, System: 31.4 ms]
    Range (min … max):    82.9 ms … 101.1 ms    28 runs
And that's without giving up a single thing in the name of quickness. Stick with zsh if you want, but understand that there are tradeoffs. And for the fish end of those tradeoffs: 1) most command lines work identically between fish, zsh, and bash; 2) where they don't, the fish version is nearly always more pleasant and obviously correct for interactive use; and 3) you don't have to uninstall bash, ya know — you can still `curl foo | sh` to run some random script off the net if you feel the desire. Your existing stuff doesn't stop working.

Re: Bringing down my ZSH load times from ~3.1s to ~230ms

#19

I have a complex fish shell configuration with ~100 autoloaded functions and about 180 lines across config.fish and a dozen conf.d/ files. On my system, hyperfine says fish loads in about 85ms: Benchmark 1: fish -il -c exit Time (mean ± σ): 85.0 ms ± 3.3 ms [User: 50.1 ms, System: 31.4 ms] Range (min … max): 82.9 ms … 101.1 ms 28 runs And that's without giving up a single thing in the name of quickness. Stick with zs…

That's a ridiculously low number. Wow! I don't think my personal mac has such speed either. I should definitely try this out.

Re: Bringing down my ZSH load times from ~3.1s to ~230ms

#20

I have a complex fish shell configuration with ~100 autoloaded functions and about 180 lines across config.fish and a dozen conf.d/ files. On my system, hyperfine says fish loads in about 85ms: Benchmark 1: fish -il -c exit Time (mean ± σ): 85.0 ms ± 3.3 ms [User: 50.1 ms, System: 31.4 ms] Range (min … max): 82.9 ms … 101.1 ms 28 runs And that's without giving up a single thing in the name of quickness. Stick with zs…

On my 6-year old PC, an interactive zsh starts more than 4 times faster, but this is a rather minor detail.

Which are in your opinion the advantages of fish over zsh?

The fish tutorial from its Web site highlights some very important advantages of fish over bash/ksh/sh, but all of them are taken from zsh, which had them long before the creation of fish (e.g. features that eliminate the need for the excessive quotation that is necessary in bash/ksh/sh).

Fish has various syntactic differences in comparison with zsh, in some places fish is more concise, but in others it is more verbose, and it is more verbose in things that are more frequently used (e.g. "set" vs. "=", "and" vs. "&&" etc.), while being more concise in things that are more rarely used.

Therefore, from the fish tutorial I see why it is preferable to bash/ksh/sh, but I see no reason to prefer it to zsh.

Post reply on HN