Startup time for default environment slow

I’ve been using flox significantly and have been trying to replace homebrew with flox. I have a default environment with all of the tools I use, but activating my default environment with every new window is pretty slow (3-5 seconds). This happens for each new terminal window I open, which is pretty frequent for me.

Is there anyway to speed this up when using the default environment?

~ on ☁️  (us-west-1) on ☁️  endallk007@gmail.com
❯ time  zsh -i -c exit
ℹ️  Upgrades are available for packages in 'kendallm/default'.
Use 'flox upgrade' to get the latest.

zsh -i -c exit  0.98s user 1.23s system 90% cpu 2.444 total

I profiled just the activate command with zprof to see what was going on with flox and there seems to be a lot of work happening. Ideally I would replace homebrew with flox for my main dev setup, but the startup time is a bit rough for me.

zmodload zsh/zprof
eval "$(flox activate -m run -d $HOME)"
zprof
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)    1         153.09   153.09   43.52%    153.09   153.09   43.52%  compdump
 2)    1         351.70   351.70   99.99%     79.38    79.38   22.57%  compinit
 3)  957          74.09     0.08   21.06%     74.09     0.08   21.06%  compdef
 4)    2          45.14    22.57   12.83%     45.14    22.57   12.83%  compaudit
 5)    1           0.05     0.05    0.01%      0.05     0.05    0.01%  add-zsh-hook

-----------------------------------------------------------------------------------

 2)    1         351.70   351.70   99.99%     79.38    79.38   22.57%  compinit
       1/2        45.14    45.14   12.83%      0.16     0.16             compaudit [4]
     957/957      74.09     0.08   21.06%     74.09     0.08             compdef [3]
       1/1       153.09   153.09   43.52%    153.09   153.09             compdump [1]

-----------------------------------------------------------------------------------

       1/1       153.09   153.09   43.52%    153.09   153.09             compinit [2]
 1)    1         153.09   153.09   43.52%    153.09   153.09   43.52%  compdump

-----------------------------------------------------------------------------------

     957/957      74.09     0.08   21.06%     74.09     0.08             compinit [2]
 3)  957          74.09     0.08   21.06%     74.09     0.08   21.06%  compdef

-----------------------------------------------------------------------------------

       1/2        45.14    45.14   12.83%      0.16     0.16             compinit [2]
       1/2        44.98    44.98   12.79%     44.98    44.98             compaudit [4]
 4)    2          45.14    22.57   12.83%     45.14    22.57   12.83%  compaudit
       1/2        44.98    44.98   12.79%     44.98    44.98             compaudit [4]

-----------------------------------------------------------------------------------

 5)    1           0.05     0.05    0.01%      0.05     0.05    0.01%  add-zsh-hook

We’ve actually made a few improvements that should land in the next release. If you want to test those out, you can grab an installer for the latest commit on main from https://shipit.flox.dev/

As a temporary workaround, it looks like you’ve pulled an environment from FloxHub. If you detach it from FloxHub with flox pull --copy that should be a little faster.

Does it feel usable after either of those, or still no? There are still some other things that we’d like to speed up

1 Like

Detaching from FloxHub helps significantly! With detaching from FloxHub, is there a better way to keep changes in sync other than force pushing?

The performance fixes are out now with Flox v1.3.13. This should apply to environments irrespective of whether they are attached to floxhub or not.