conda-forge / miniforge

A conda-forge distribution.
https://conda-forge.org/miniforge
Other
6.06k stars 317 forks source link

Slow zsh startup on MacBook pro 14" (M1 Pro) #296

Open synchroazel opened 2 years ago

synchroazel commented 2 years ago

Solution to issue cannot be found in the documentation.

Issue

Hi there o/ I recently installed Miniforge on my MacBook Pro 14" with M1 Pro, and the startup time of Terminal increased to 4-5 seconds (it was < 1 sec before Miniforge, when I had Anaconda). Without the .zshrc file, located in my home folder, the terminal startup is fast again.

Here is the content of my .zshrc file:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/azel/miniforge3/bin/conda' 'shell.zsh' 'hook' 2> /dev/$
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/azel/miniforge3/etc/profile.d/conda.sh" ]; then
        . "/Users/azel/miniforge3/etc/profile.d/conda.sh"
    else
        export PATH="~/miniforge3/bin:$PATH"
    fi
fi
unset __conda_setup

# <<< conda initialize <<<

Is that some issue related to Miniforge? Is it possible to achieve faster Terminal startup times?

Installed packages

# packages in environment at /Users/azel/miniforge3:
#
# Name                    Version                   Build  Channel
aom                       3.3.0                h07bb92c_1    conda-forge
appnope                   0.1.3                    pypi_0    pypi
argon2-cffi               21.3.0                   pypi_0    pypi
argon2-cffi-bindings      21.2.0                   pypi_0    pypi
asttokens                 2.0.5                    pypi_0    pypi
attrs                     21.4.0                   pypi_0    pypi
backcall                  0.2.0                    pypi_0    pypi
beautifulsoup4            4.11.1                   pypi_0    pypi
bleach                    5.0.0                    pypi_0    pypi
brotlipy                  0.7.0           py39h5161555_1003    conda-forge
bzip2                     1.0.8                h3422bc3_4    conda-forge
ca-certificates           2021.10.8            h4653dfc_0    conda-forge
certifi                   2021.10.8        py39h2804cbe_2    conda-forge
cffi                      1.15.0           py39h52b1de0_0    conda-forge
charset-normalizer        2.0.12             pyhd8ed1ab_0    conda-forge
click                     7.0                      pypi_0    pypi
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
conda                     4.12.0           py39h2804cbe_0    conda-forge
conda-package-handling    1.8.0            py39hb18efdd_0    conda-forge
cryptography              36.0.2           py39hbe5e4b8_0    conda-forge
cycler                    0.11.0                   pypi_0    pypi
debugpy                   1.6.0                    pypi_0    pypi
decorator                 5.1.1                    pypi_0    pypi
defusedxml                0.7.1                    pypi_0    pypi
entrypoints               0.4                      pypi_0    pypi
executing                 0.8.3                    pypi_0    pypi
fastjsonschema            2.15.3                   pypi_0    pypi
ffmpeg                    4.4.1                h2f96316_2    conda-forge
fonttools                 4.32.0                   pypi_0    pypi
freetype                  2.10.4               h17b34a0_1    conda-forge
future                    0.18.2                   pypi_0    pypi
gettext                   0.19.8.1          h049c9fb_1008    conda-forge
giflib                    5.2.1                h27ca646_2    conda-forge
gmp                       6.2.1                h9f76cd9_0    conda-forge
gnutls                    3.6.13               h706517b_1    conda-forge
icu                       70.1                 h6b3803e_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
ipykernel                 6.13.0                   pypi_0    pypi
ipython                   8.2.0                    pypi_0    pypi
ipython-genutils          0.2.0                    pypi_0    pypi
ipywidgets                7.7.0                    pypi_0    pypi
jbig                      2.1               h3422bc3_2003    conda-forge
jedi                      0.18.1                   pypi_0    pypi
jinja2                    3.1.1                    pypi_0    pypi
joblib                    1.1.0                    pypi_0    pypi
jpeg                      9e                   h1c322ee_1    conda-forge
jsonschema                4.4.0                    pypi_0    pypi
jupyter                   1.0.0                    pypi_0    pypi
jupyter-client            7.2.2                    pypi_0    pypi
jupyter-console           6.4.3                    pypi_0    pypi
jupyter-core              4.9.2                    pypi_0    pypi
jupyterlab-pygments       0.2.1                    pypi_0    pypi
jupyterlab-widgets        1.1.0                    pypi_0    pypi
kaggle                    1.5.12                   pypi_0    pypi
kiwisolver                1.4.2                    pypi_0    pypi
lame                      3.100             h27ca646_1001    conda-forge
lcms2                     2.12                 had6a04f_0    conda-forge
lerc                      3.0                  hbdafb3b_0    conda-forge
libblas                   3.9.0           14_osxarm64_openblas    conda-forge
libcblas                  3.9.0           14_osxarm64_openblas    conda-forge
libcxx                    13.0.1               h6a5c8ee_0    conda-forge
libdeflate                1.10                 h3422bc3_0    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libgfortran               5.0.0.dev0      11_0_1_hf114ba7_23    conda-forge
libgfortran5              11.0.1.dev0         hf114ba7_23    conda-forge
libiconv                  1.16                 h642e427_0    conda-forge
liblapack                 3.9.0           14_osxarm64_openblas    conda-forge
libopenblas               0.3.20          openmp_h2209c59_0    conda-forge
libpng                    1.6.37               hf7e6567_2    conda-forge
libprotobuf               3.19.4               hccf11d3_0    conda-forge
libtiff                   4.3.0                h77dc3b6_3    conda-forge
libvpx                    1.11.0               hc470f4d_3    conda-forge
libwebp                   1.2.2                h0d20362_0    conda-forge
libwebp-base              1.2.2                h3422bc3_1    conda-forge
libxcb                    1.13              h9b22ae9_1004    conda-forge
libxml2                   2.9.13               h97d9dda_0    conda-forge
libzlib                   1.2.11            hee7b306_1013    conda-forge
llvm-openmp               13.0.1               h455960f_1    conda-forge
lz4-c                     1.9.3                hbdafb3b_1    conda-forge
markupsafe                2.1.1                    pypi_0    pypi
matplotlib                3.5.1                    pypi_0    pypi
matplotlib-inline         0.1.3                    pypi_0    pypi
mistune                   0.8.4                    pypi_0    pypi
nbclient                  0.6.0                    pypi_0    pypi
nbconvert                 6.5.0                    pypi_0    pypi
nbformat                  5.3.0                    pypi_0    pypi
ncurses                   6.3                  hc470f4d_0    conda-forge
neobolt                   1.7.17                   pypi_0    pypi
neotime                   1.7.4                    pypi_0    pypi
nest-asyncio              1.5.5                    pypi_0    pypi
nettle                    3.6                  hc6a1b29_0    conda-forge
ninja                     1.10.2               hc021e02_1    conda-forge
nltk                      3.7                      pypi_0    pypi
notebook                  6.4.10                   pypi_0    pypi
numpy                     1.22.3           py39h690d673_2    conda-forge
oauthlib                  3.2.0                    pypi_0    pypi
openh264                  2.1.1                habe5f53_0    conda-forge
openjpeg                  2.4.0                h062765e_1    conda-forge
openssl                   1.1.1n               h90dfc92_0    conda-forge
packaging                 21.3                     pypi_0    pypi
pandas                    1.4.2                    pypi_0    pypi
pandocfilters             1.5.0                    pypi_0    pypi
parso                     0.8.3                    pypi_0    pypi
pexpect                   4.8.0                    pypi_0    pypi
pickleshare               0.7.5                    pypi_0    pypi
pillow                    9.1.0            py39hd72dd6b_2    conda-forge
pip                       22.0.4             pyhd8ed1ab_0    conda-forge
prometheus-client         0.14.1                   pypi_0    pypi
prompt-toolkit            2.0.10                   pypi_0    pypi
psutil                    5.9.0                    pypi_0    pypi
pthread-stubs             0.4               h27ca646_1001    conda-forge
ptyprocess                0.7.0                    pypi_0    pypi
pure-eval                 0.2.2                    pypi_0    pypi
py2neo                    4.3.0                    pypi_0    pypi
pycosat                   0.6.3           py39h5161555_1009    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.11.2                   pypi_0    pypi
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.8                    pypi_0    pypi
pyrsistent                0.18.1                   pypi_0    pypi
pysocks                   1.7.1            py39h2804cbe_4    conda-forge
python                    3.9.10          hd16f9c5_2_cpython    conda-forge
python-dateutil           2.8.2                    pypi_0    pypi
python-slugify            6.1.1                    pypi_0    pypi
python_abi                3.9                      2_cp39    conda-forge
pytorch                   1.11.0          cpu_py39h19aa3d3_0    conda-forge
pytumblr                  0.1.0                    pypi_0    pypi
pytz                      2022.1                   pypi_0    pypi
pyzmq                     22.3.0                   pypi_0    pypi
qtconsole                 5.3.0                    pypi_0    pypi
qtpy                      2.0.1                    pypi_0    pypi
readline                  8.1                  hedafd6a_0    conda-forge
regex                     2022.3.15                pypi_0    pypi
requests                  2.27.1             pyhd8ed1ab_0    conda-forge
requests-oauthlib         1.3.1                    pypi_0    pypi
ruamel_yaml               0.15.80         py39h5161555_1006    conda-forge
send2trash                1.8.0                    pypi_0    pypi
setuptools                60.10.0          py39h2804cbe_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sleef                     3.5.1                h156473d_2    conda-forge
soupsieve                 2.3.2                    pypi_0    pypi
sqlite                    3.37.1               h7e3ccbd_0    conda-forge
stack-data                0.2.0                    pypi_0    pypi
svt-av1                   0.9.1                h07bb92c_0    conda-forge
terminado                 0.13.3                   pypi_0    pypi
text-unidecode            1.3                      pypi_0    pypi
tinycss2                  1.1.1                    pypi_0    pypi
tk                        8.6.12               he1e0b03_0    conda-forge
torchvision               0.12.0                   pypi_0    pypi
tornado                   6.1                      pypi_0    pypi
tqdm                      4.63.0             pyhd8ed1ab_0    conda-forge
traitlets                 5.1.1                    pypi_0    pypi
typing_extensions         4.2.0              pyha770c72_1    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
urllib3                   1.24.3                   pypi_0    pypi
wcwidth                   0.2.5                    pypi_0    pypi
webencodings              0.5.1                    pypi_0    pypi
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
widgetsnbextension        3.6.0                    pypi_0    pypi
wordcloud                 1.8.1                    pypi_0    pypi
x264                      1!161.3030           h3422bc3_1    conda-forge
x265                      3.5                  hbc6ce65_3    conda-forge
xorg-libxau               1.0.9                h27ca646_0    conda-forge
xorg-libxdmcp             1.1.3                h27ca646_0    conda-forge
xz                        5.2.5                h642e427_1    conda-forge
yaml                      0.2.5                h3422bc3_2    conda-forge
zlib                      1.2.11            hee7b306_1013    conda-forge
zstd                      1.5.2                h861e0a7_0    conda-forge

Environment info

active environment : base
    active env location : /Users/azel/miniforge3
            shell level : 1
karlglazebrook commented 1 year ago

I've noticed the same issue on an intel iMac where I freshly installed Monterey (12.6.1) and Anaconda (2022.10). It is really annoying!

hmaarrfk commented 1 year ago

I've noticed slow startups too on my Mac. But I'm going to say. We are not anaconda. We can only help with Miniforge questions.

I think it has to do with some telemetry of Mac . Not too sure.

jakirkham commented 1 year ago

Am also on a Mac (M1 Pro) and use Miniforge. Have not noticed this issue.

It is worth noting that there are quite a few packages in the base environment (listed above). Generally it is recommended to keep the base environment slim and install other things in new environments. Not sure whether this is the cause of the issue, but it could be part of it

synchroazel commented 1 year ago

At the time I wrote this, I just moved eval "$(/<path-to-conda>/bin/conda shell.zsh hook)" which was previously in my .zshrc to a shell file in my home and symlinked it to anaconda, so that I could start anaconda only when I want it, and not every time I open up a terminal. I understand it’s not a solution, but it was a nice way to "speed up" my terminal startup.

But recently I happened to reinstall miniforge, and the problem was not there anymore. I'd say it is probably as @jakirkham said, since I've left the base environment untouched since the reinstall.

wyq977 commented 1 year ago

@jakirkham Hi did you notice a difference in the following cases?

  1. disable # >>> conda initialize >>> part
  2. conda config --set auto_activate_base false (do not activate base env)
  3. with # >>> conda initialize >>> in bash_profile or zprofile (default)

I find the time in each terminal startup is 1<2<3.

I am more interested if you find a time diff. in case 1 and 2.

Thx

erentar commented 3 months ago

What sort of operations take place during this startup period? Is it possible to slim it down, maybe profiling it?

karlglazebrook commented 3 months ago

I think I figured this out, at least in my case. My workplace had some compulsory software installed on my Mac. including Microsoft Defender. This scans every single file opened, in the case of Anaconda startup this is likely thousands of teeny python files causing a several second slowdown.

If I stop this scanning from happening, by telling it to exclude the whole anaconda file tree, then startup is now snappy again.