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
I've been optimising the loading time of my fish config and I noticed that loading universals from fish_variables is much faster than using globals in config.fish.
My config.fish pretty much only exports variables, creates some aliases and abbreviations.
Before my optims, my config.fish used:
set -x
alias
abbr -g
Using hyperfine fish -ic exit, this gave a mean of 75ms
After my optims, I used the universal equivalents:
set -Ux
alias -s
abbr -U
At the top of my config file, I added the following code:
This will only execute the rest of my config, if the file was changed since we last read it.
Using hyperfine fish -ic exit, now gives a mean of 11ms, which is almost 7x faster without losing any functionality.
The baseline, with an empty config file on my machine is 8.7ms, so there's only an overhead of 2.3ms to load all my abbreviations, aliases and exports.
It might be a good idea to have this kind of configuration to be part of fish where you can add all universal stuff to config_universal.fish, which then only is executed if the file was changed.
Activity
faho commentedon Oct 28, 2020
No, thanks. Universal variables are already stored, so there's no point in storing them twice.
Use your own file in conf.d with a guard variable if you must.
ridiculousfish commentedon Nov 8, 2020
I will open another issue to discuss this, we may be able to extract a benchmark at least.