MSYS2-packages: All tools from shell are very slow
Any tool I run in msys2 shell (ls, mv, …) are very slow. Simply ls takes something like 3 seconds.
Running “strace ls” I see following output:
15 39327 [main] ls 7460 DLL build: 2014-11-21 06:38
16 39343 [main] ls 7460 dtable::extend: size 32, fds 0x1802FB488
381 39724 [main] ls 7460 transport_layer_pipes::connect: Try to connect to named pipe: \\.\pipe\msys-07c9b4f1c823d951-lpc
40 39764 [main] ls 7460 transport_layer_pipes::connect: Error opening the pipe (2)
31 39795 [main] ls 7460 client_request::make_request: cygserver un-available
--- Process 7460, exception 00000000 at 000007FEFD22940D
1804450 1844245 [main] ls 7460 reg_key::build_reg: failed to create key ServicesForNFS in the registry
2011 1846256 [ldap_init] ls 7460 cygthread::stub: thread 'ldap_init', id 0x2410, stack_ptr 0x2FCAC90
310497 2156753 [main] ls 7460 pwdgrp::fetch_account_from_windows: line: <...USERNAME...:*:1599881:1049089:....SOME_REGISTRY_KEY...:/home/...USERNAME...:/usr/bin/bash>
6571 2163324 [main] ls 7460 pwdgrp::fetch_account_from_windows: line: <Domain Users:S-1-5-21-1915207013-2615040368-3076929458-513:1049089:>
768 2164092 [main] ls 7460 pwdgrp::fetch_account_from_windows: line: <Performance Log Users:S-1-5-32-559:559:>
402 2164494 [main] ls 7460 pwdgrp::fetch_account_from_windows: line: <Users:S-1-5-32-545:545:>
Could slowness be related to this? I am on non-admin user on this machine… Can that be avoided?
About this issue
- Original URL
- State: open
- Created 10 years ago
- Reactions: 14
- Comments: 59 (26 by maintainers)
I also faced the same issue with KrullKorg and legends2k’s case. I found that expansion of
~*
was very slow. I had to update/etc/passwd
and/etc/group
, then disable db in nsswitch.conf. More detail: https://gist.github.com/k-takata/9b8d143f0f3fef5abdabi “solved” disabling db in nsswitch.conf
With a new msys2 installation today, I observed every process, the initial
bash.exe
spawned bymintty.exe
as well as every process spawned by bash, taking ~1s to ~3s to start.strace bash 2>&1 | ts
revealed all the time was spent before the first line out of output from strace, suggesting it was part of the process startup itself.I tried the
nsswitch.conf
technique in the comments above but it did not change anything. (I believe Cygwin had got a patch to make the workaround unnecessary, and perhaps msys2 has had that same patch as well.)So I traced
bash.exe
through procmon and observed it spending ~500ms on every startup enumerating ~8k files that matchC:\Windows\System32\catroot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\*.cat
, each with a callstack containingappid.sys
(the AppLocker driver). That led me to this page, and indeed my machine has AppLocker policies enabled (*). After code-signing all binaries underC:\msys64\usr\bin
as that page suggests (cd C:\msys64\usr\bin\; gci -re *.exe | %{ &'C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe' sign /a /uw $_.FullName }
), all msys2 process start nearly instantaneously.(*)
secpol.msc
actually says there are no AppLocker policies, butGet-AppLockerPolicy -Effective
clearly lists several.Yeah, eventually I found the file and commented out ‘#db’ for the:‘group’. But that doesn’t help. Everything is extremely slow.
Disabling db from both passwd and group fixed the issue but led to my username being unrecognised (bash prompt showed me as Unknown+User). However, the “fix” was to just disable db from group and leave passwd as it was, and this sped up MSYS2 utilities like
diff
,which
,ls
and also the startup of MSYS2 significantly.This is great. Commenting out “db” from nsswitch.conf helps. Now all operations are fast for me.
Slow +1
I was talking about msys2 as a domain user, msys2 on normal windows installations is quick, so there is some networking happening, idk what, or maybe it’s the antivirus checking every I/O, 🤷
Are we sure is bash? I just noticed something, when I run
make
it throws tons of exception in the background? I am not exactly sure what I’m doing, but I ran astrace make
(because that’s what was being super slow).And it looks like internally it spwns a bash shell and then it throws an insane amount of “internal exception”?
Thoughts?
I too experienced extreme slowness on Win 10. This fixed it for me:
mkpasswd > /etc/passwd
mkgroup > /etc/group
Then comment out mentions of
db
in/etc/nsswitch.conf
and restart msys2. Moving at a usable clip now.I think the AV is called Avast. I have uninstalled it.
@legends2k I think I have found the problem: my Anti-Virus software has been dragging every single one of my commands. Disabling it doesn’t change the game. Once I completely removed the anti-virus software, everything started working again. Just to let you know. Thanks.
unfortunately now some commands are slower than some time ago; for example: ls, git status/diff, configure (autoreconf), gitk