Cygwin a bit slow
Christian Franke
Christian.Franke@t-online.de
Wed Apr 10 10:34:02 GMT 2024
J M via Cygwin wrote:
> ...
>
> Specifically for this problem, I have investigated the problem and can be
> related to pipes and antivirus.
>
> Specifically
> while true
> do
> echo ABC | grep AAA
> done
>
> It makes the cpu of that antivirus go up.
This is as expected because malware scanners hook into Win32 API's
CreateProcess*() calls which are also used by the fork()/exec()
emulation of Cygwin. Each run of 'grep' above uses at least two
CreateProcess*() calls.
This quick test shows how many 'date' commands could be run per second:
$ while :; do date +%s; done | uniq -c
...
65 1712742865 <== Windows Defender off
66 1712742866
66 1712742867
64 1712742868
61 1712742869
51 1712742870 <== Windows Defender turned on
51 1712742871
49 1712742872
45 1712742873
53 1712742874
54 1712742875
...
The above could even slow down to 1-2 per second with certain malware
scanners if expensive heuristics (which may also generate a lot of false
positives, BTW) is enabled. So one problem is the lousy performance of
CreateProcess*() calls. This is not Cygwin-specific but affects typical
Cygwin use cases like shell scripts.
Using bash builtins in the above example speeds it up to ~21000/second
on the same very old box:
$ while :; do printf '%(%s)T\n'; done | uniq -c
--
Regards,
Christian
More information about the Cygwin
mailing list