prezto icon indicating copy to clipboard operation
prezto copied to clipboard

adding node module slows startup time

Open cabello opened this issue 6 years ago • 6 comments

Hi 👋

Related issue #1230

Description

When compared to oh-my-zsh, Prezto is fast! I am comparing 1s to 100ms.

However as soon as one adds the node module which loads NVM, a whole second or more is added to the startup time. There was a long discussion https://github.com/robbyrussell/oh-my-zsh/issues/5327 and some people found clever solutions. The one I like the most is only loading nvm once a node related command is executed.

Expected behavior

Modules should be lightweight and barely change the speed of the terminal experience.

Actual behavior

As soon as node is installed the startup time slows down by a few seconds.

Steps to Reproduce

  1. add node to your module list
  2. open a new terminal while paying attention to when you get the first prompt

Versions

  • Prezto commit: 4abbc5572149baa6a5e7e38393a4b2006f01024f
  • ZSH version: 5.6.2 (x86_64-apple-darwin18.2.0)
  • OS information: macOS Mojave 10.14.2

Thanks 💚

cabello avatar Jan 23 '19 20:01 cabello

Do you use NVM? I have that behaviour with NVM loaded as a plugin or if I source it manually.

muuvmuuv avatar Jul 16 '19 06:07 muuvmuuv

@muuvmuuv I use nodenv and it's part of the reason why it's slow, if I recall correctly I fixed this by making nodenv lazy, meaning it doesn't always check or load on every cd, but only when I trigger something that would need node.

cabello avatar Jul 16 '19 12:07 cabello

So it is more like a nodenv/nvm issue than a prezto performance problem. I experience exactly the same with NVM...

muuvmuuv avatar Jul 17 '19 07:07 muuvmuuv

Benchmarked with time zsh -i -c exit.

With node: 0.56s Without node: 0.07s

Node module removed until fixed.

nomasprime avatar Jan 17 '20 16:01 nomasprime

@muuvmuuv how did you fix? Was there a PR?

nomasprime avatar Jan 17 '20 16:01 nomasprime

I have just removed the auto script (I mean the node plugin) and initial NVM manually which is fine

muuvmuuv avatar Jan 19 '20 12:01 muuvmuuv