You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
% zsh -fc 'local -a a; time ( repeat 5000 { a+=(foo) } )'
( repeat 5000;do; a+=(foo) ;done; ) 1.26s user 0.00s system 99% cpu 1.268 total
% zsh -fc 'local -a a; time ( repeat 10000 { a+=(foo) } )'
( repeat 10000;do; a+=(foo) ;done; ) 5.02s user 0.00s system 99% cpu 5.028 total
% zsh -fc 'local -a a; time ( repeat 20000 { a+=(foo) } )'
( repeat 20000;do; a+=(foo) ;done; ) 19.94s user 0.08s system 99% cpu 20.036 total
So:
Around a quarter of syntax highlighting runtime is due to array appends.
Array appends are O(n²) (using zsh 5.1.1-test-1, i.e., a 5.1.2 prerelease).
75% of the runtime is in _zsh_highlight_main_highlighter itself.
Action items:
Follow up with zsh upstream about quadratic behaviour. Done in workers/37236
Make any necessary fixes in zsh upstream
Investigate the 75% that are in _zsh_highlight_main_highlighter.
Highlighting of long, multiline buffers is slow.
Example:
fned compdef
(and type<SPACE>
to trigger highlighting after the buffer loads).zprof:
Breaking out the last line of
_zsh_highlight_main_add_region_highlight
` to its own anonymous function gives:And indeed:
So:
_zsh_highlight_main_highlighter
itself.Action items:
_zsh_highlight_main_highlighter
.ZSH_HIGHLIGHT_MAXLENGTH
(including the tip from Add ability to temporarily disable highlighting #86).Status: spun off to Document ZSH_HIGHLIGHT_MAXLENGTH #698.
The text was updated successfully, but these errors were encountered: