From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout05.t-online.de (mailout05.t-online.de [194.25.134.82]) by sourceware.org (Postfix) with ESMTPS id EA0A83858D20 for ; Wed, 10 Apr 2024 10:34:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA0A83858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=t-online.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EA0A83858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=194.25.134.82 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712745251; cv=none; b=Xvl3SMsNeI7v5dEXuTP0osnYMGaAGJ46CxIpb770uqbL12949a2e495I25Rfq6eh3/Uf1aHe6nZZ7kIkASW4wc3ZnEhbvUdIetHnX/zcDsAKvBWBt126TFGE8HKEM/NRAn6C9wMa8cZKWkskDnHi13KMtUgb5WAczZyE5LGZgD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712745251; c=relaxed/simple; bh=m3voMasKjkwEYuNWYLug1c4Ikk9JxFPl6wy3G4p34a0=; h=Subject:To:From:Message-ID:Date:MIME-Version; b=Zt+txsoZAIcs80PCLPffe9iMbnXzTedBU8ueCjhmd1z0Q3GSDt9WxFf2sjqV6GU1P8HdvKhRS1SzRxB4J26+VN/x1nKYBX7RqbD4CkRO7avgUwyL5V/z6xScP1GPVBMBi6go3lIXyn0tMqWuyqPE45+k60jSBx1qV4vkqA2E7Dg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from fwd82.aul.t-online.de (fwd82.aul.t-online.de [10.223.144.108]) by mailout05.t-online.de (Postfix) with SMTP id 971F0227E2 for ; Wed, 10 Apr 2024 12:34:05 +0200 (CEST) Received: from [192.168.2.101] ([79.230.172.235]) by fwd82.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1ruVHH-4d5bm40; Wed, 10 Apr 2024 12:34:03 +0200 Subject: Re: Cygwin a bit slow To: cygwin@cygwin.com References: Reply-To: cygwin@cygwin.com From: Christian Franke Message-ID: Date: Wed, 10 Apr 2024 12:34:02 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 SeaMonkey/2.53.16 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TOI-EXPURGATEID: 150726::1712745243-527FBD74-2996C9B9/0/0 CLEAN NORMAL X-TOI-MSGID: 6332dcf5-79ad-4a75-83b7-5c4925260df3 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FROM,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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