Thank you for your work on this plugin! It's an essential one for me, coming from Fish. That said, it's also by far the slowest Zsh plugin I use and I was wondering if there's a performance tuning effort on the roadmap, if you've identified places where focusing on performance would have the biggest impact, or if you would accept PRs that address performance tuning?
When running /usr/bin/time zsh -i -c exit
, my Zsh startup times jump from 0.10 real 0.05 user 0.03 sys
to 0.29 real 0.13 user 0.13 sys
when adding zsh-abbr. I use about 20 other plugins if that gives some context. Perhaps I'm spoiled by Fish's speed, but anything over .15 can feel really sluggish.
I have had great luck loading this plugin via zsh-defer, which waits until Zle is idle to do the work of loading a plugin, thus getting you to a prompt quicker. My times then drop to 0.05 real 0.02 user 0.02 sys
. I think this is similar to what zinit does, but not everyone likes/uses zinit.
An alternative to performance tuning the existing code might be to carve out the core concepts from zsh-defer and implement a mini-defer within zsh-abbr itself to accomplish the same thing without changing any other code. I'm happy to help, but don't want to go down the wrong path here if some thought has already gone into how to achieve better performance from this plugin.
Again, thank you so much for the work on this!
As a reference, this is my topline zprof
results:
num calls time self name
-----------------------------------------------------------------------------------
1) 47 147.62 3.14 64.41% 140.42 2.99 61.27% _abbr:util_add
2) 1 24.53 24.53 10.70% 24.52 24.52 10.70% _abbr_deprecations:widgets
3) 48 10.84 0.23 4.73% 10.84 0.23 4.73% _abbr_no_color
4) 47 171.99 3.66 75.05% 10.36 0.22 4.52% _abbr
5) 1 229.18 229.18 100.00% 10.28 10.28 4.49% _abbr_init
6) 1 9.83 9.83 4.29% 9.83 9.83 4.29% _abbr_job_push:wait_turn
7) 294 4.42 0.02 1.93% 4.42 0.02 1.93% _abbr_debugger
8) 1 177.28 177.28 77.35% 3.07 3.07 1.34% _abbr_load_user_abbreviations:load
9) 1 2.88 2.88 1.26% 2.87 2.87 1.25% _abbr_job_pop
10) 47 151.10 3.21 65.93% 2.82 0.06 1.23% _abbr:add
11) 47 3.06 0.07 1.34% 2.12 0.05 0.92% _abbr:util_check_command
12) 47 174.20 3.71 76.01% 1.66 0.04 0.72% abbr
13) 1 1.42 1.42 0.62% 1.42 1.42 0.62% colors
14) 47 2.15 0.05 0.94% 1.19 0.03 0.52% _abbr:util_sync_user
15) 1 11.20 11.20 4.89% 1.03 1.03 0.45% _abbr_job_push
16) 47 1.43 0.03 0.62% 0.83 0.02 0.36% _abbr:util_log_unless_quiet
17) 1 177.92 177.92 77.63% 0.49 0.49 0.21% _abbr_load_user_abbreviations
18) 1 24.87 24.87 10.85% 0.33 0.33 0.14% _abbr_deprecations
19) 1 0.32 0.32 0.14% 0.31 0.31 0.13% _abbr_job_push:add_job
20) 1 0.15 0.15 0.06% 0.15 0.15 0.06% add-zsh-hook
21) 1 0.09 0.09 0.04% 0.07 0.07 0.03% _abbr_create_files
22) 1 0.08 0.08 0.03% 0.07 0.07 0.03% _abbr_bind_widgets
23) 1 0.05 0.05 0.02% 0.04 0.04 0.02% _abbr_add_widgets
24) 1 0.14 0.14 0.06% 0.03 0.03 0.01% _abbr_load_user_abbreviations:setup