Skip to content

Proposal: config_universal.fish #7432

Closed

Description

@folke

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:

set -l fish_config_mtime (stat -f %m $__fish_config_dir/config.fish)
if test "$fish_config_changed" = "$fish_config_mtime"
    exit
else
    set -U fish_config_changed $fish_config_mtime
end

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.

Any thoughts?

Activity

  1. faho commented on Oct 28, 2020

    @faho
    Member

    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.

  2. added this to the will-not-implement milestone on Oct 28, 2020
  3. ridiculousfish commented on Nov 8, 2020

    @ridiculousfish
    Member

    I will open another issue to discuss this, we may be able to extract a benchmark at least.

  4. locked as resolved and limited conversation to collaborators on May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions