powerlevel9k icon indicating copy to clipboard operation
powerlevel9k copied to clipboard

[Performance] startup time increases dramatically on branch "next"

Open laggardkernel opened this issue 6 years ago • 0 comments

Just noticed the startup time increased dramatically on branch "next" compared with branch "master".

branch default conf 0 segment
master 40 ms 35 ms
next 476 ms 71 ms

The above result is got from plugin manager zplugin and bytecode compiling is used for each zsh file. Tested on my laptop with an SSD. There's a perceptible delay on prompt's first rendering.

After some digging, I find out the overhead is caused by the anonymous function within each segment, mainly the p9k::register_segment calls.

TIMEFMT=$'real %E user %U sys %S  cpu %P total %*E'

time (p9k::register_segment "DIR" 'DEFAULT' "blue" "$DEFAULT_COLOR" '' $'\uE818' $'\uF115' '\u'${CODEPOINT_OF_AWESOME_FOLDER_O} $'\uF115')
0.01s user 0.01s system 98% cpu 0.023 total

time (p9k::set_default P9K_DIR_PATH_SEPARATOR "/")
0.00s user 0.00s system 72% cpu 0.002 total

Causes of the problem

  • inefficient, or too many helpers (most slowed by p9k::find_first_defined)
  • icon and color register is done too early. The corresponding segment may not be rendered at precmd at all

xtrace result of p9k::register_segment

laggardkernel avatar Jul 03 '19 03:07 laggardkernel