From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) by sourceware.org (Postfix) with ESMTPS id 0502E3858400 for ; Tue, 31 Aug 2021 15:08:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0502E3858400 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MbC5g-1msEGH1y6i-00beL4 for ; Tue, 31 Aug 2021 17:08:01 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id E3F43A80D9A; Tue, 31 Aug 2021 17:08:00 +0200 (CEST) Date: Tue, 31 Aug 2021 17:08:00 +0200 From: Corinna Vinschen To: cygwin-developers@cygwin.com Subject: Re: cygrunsrv + sshd + rsync = 20 times too slow -- throttled? Message-ID: Reply-To: cygwin-developers@cygwin.com Mail-Followup-To: cygwin-developers@cygwin.com References: <20210831175534.21edae2356d74a0750c686de@nifty.ne.jp> <20210831182500.4c1c67dae13f51ca68964f63@nifty.ne.jp> <20210831204541.2b56702cdcd2fae5e91ba8e2@nifty.ne.jp> <20210831213110.6c74574c7c43ff85c19cc175@nifty.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210831213110.6c74574c7c43ff85c19cc175@nifty.ne.jp> X-Provags-ID: V03:K1:THXtpNURYTivlOk2ILS5YmnEjTDyeKJEsdbgRO0ZnzRCjP+20Wv 2rnXex+P2stnz87MwcPnHqu/H6aZ2lObEINI5FrenlE4VaFhZ+FHaBdfVryrusvux7AwktY 3lH8AjHK9jb9gOf/1ARFr1pQ60wS0csd/9ghYZTPyaa4xhAlZC12BJwfKTzbIFh+S6UKmh5 R0PLfu7vAYQdLgpdVqhJA== X-UI-Out-Filterresults: notjunk:1;V03:K0:96epUCDXkEg=:CGAoje4OfOcjo8rg0Tcl0F tVjJTl+6kVLvpOhSXm6RBezD4DsbbpQ7bf5mSARkTPjtfxlLvEcE7GoMuJNEnK74oDfvxnKvI 5cHS+guaJLoERyBIdd9hsJyWxnJOP6KSxQ0LsTZ+Nq4649oaxl37MTvaLLelhbVIXWtili8Yn w09nJ4Hk8/fWS9UL/zPRMWkhaiYdglnCjhLFS55kzyPo+9uW23dvrY/xJO56EcJsx5waTUpHU DgjzvRwxjUP7KaLCEo+v+3gGa9E0OCP7SQduQHks9lnBn4bs18Zv5LtbWjoFfu8VDhUjVammJ acqFIt+GurLnkMoKjXxlOL6JHp2sSWKxWyejqCT5zWw8FMdv51Tsk9IEGodWa2AOEtYknZKo3 VLAZGf9IwLqacC1r/Z0He4x1nKZ9wqpxq2eGCrc186H3v5uzqX3HMerV3qxhmlJcvrrbsIOkw biSJqVsT4Kg8CbkyA/mY9/q8Khgqrn9aG05Ju2sjGR2KNu2/vpSRMsCVdPbcPZte7Cz4YGXnw 0snFrn4JJi0sZZ5naoFXf6GF1y5qfu8ot+U03QvnSL0SGKqa8QSaxDWaDn9knLcm3EpEv5yLw TaMCdUF3P974BsPkqPM0wRMXG/kh77Kn0QGItZ3Bm/9WH+MocU9inEWg7Fl2WeivPzkrECPiq lpiFzmMBeq9oFnkQDX9GGXmq7UaNrB++4hym1u9PsiKAW7lmvoWLx4qoNqrd7cKM1WnQtQXyx owDsorJRXFVSLVeqpVU89N3lXCeNrrxSVNu3wJWOUGBdnNW9/tupIQ9FWQk= X-Spam-Status: No, score=-105.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, GOOD_FROM_CORINNA_CYGWIN, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2021 15:08:04 -0000 On Aug 31 21:31, Takashi Yano wrote: > On Tue, 31 Aug 2021 20:45:41 +0900 > Takashi Yano wrote: > > On Tue, 31 Aug 2021 12:18:57 +0200 > > Corinna Vinschen wrote: > > > Please try the attached patch on top of topic/pipe. > > > > Thanks for the new patch. I have confirmed that above issue > > is fixed and select() for write pipe seems to work as expected. > > > > > > BTW, I found one minor difference between Linux and this pipe > > implementation. > > > > The test case is attached. The test case uses non-bloking I/O. > > If this STC runs on Linux, the result is: > > > > 1024/1024 > > 1740/1740 > > 2958/2958 > > 5028/5028 > > 8547/8547 > > 14529/14529 > > 24699/24699 > > 41988/41988 > > 22227/71379 > > 65536/121344 > > 65536/206284 > > Total: 247KB in 0.000612 second, 403517.628166KB/s > > > > On cygwin 3.2.0, the result is similar to Linux. > > > > 1024/1024 > > 1740/1740 > > 2957/2957 > > 5026/5026 > > 8544/8544 > > 14524/14524 > > 24690/24690 > > 41972/41972 > > 65536/71352 > > 65536/121298 > > 65536/206206 > > Total: 290KB in 0.062653 second, 4628.669018KB/s > > > > > > However, on topic/pipe implementation, the result is > > > > 1024/1024 > > 1740/1740 > > 2957/2957 > > 5026/5026 > > 8544/8544 > > 14524/14524 > > 24690/24690 > > -1/41972 > > w-1/71352 > > w-1/121298 > > w-1/206206 > > wTotal: 57KB in 0.000330 second, 172989.377845KB/s > > > > In non-blocking mode, writing more than pipe space will fail with > > EAGAIN in this implementation. > > > > In Linux and cygwin 3.2.0, it seems to write as much as writable. > > > > Is this difficult to be fixed? > > The following patch almost fixes the issue, but atomicity is the problem. Thanks, I took the liberty to use your idea to implement a loop trying to write again. For me the output is now 1024/1024 1740/1740 2958/2958 5028/5028 8547/8547 14529/14529 24699/24699 7011/41988 65536/71379 65536/121344 65536/206284 Total: 256KB in 0.017771 second, 14405.248913KB/s Could you try again with this patch? I'm glad if we can straighten out the bugs :) diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc index 2dec0a84817c..0aed8456bb0b 100644 --- a/winsup/cygwin/fhandler_pipe.cc +++ b/winsup/cygwin/fhandler_pipe.cc @@ -352,8 +352,30 @@ fhandler_pipe::raw_write (const void *ptr, size_t len) else len1 = (ULONG) left; nbytes_now = 0; - status = NtWriteFile (get_handle (), evt, NULL, NULL, &io, - (PVOID) ptr, len1, NULL, NULL); + while (true) + { + status = NtWriteFile (get_handle (), evt, NULL, NULL, &io, + (PVOID) ptr, len1, NULL, NULL); + if (evt || !NT_SUCCESS (status) || io.Information > 0) + break; + + FILE_PIPE_LOCAL_INFORMATION fpli; + IO_STATUS_BLOCK qio; + + if (!NT_SUCCESS (NtQueryInformationFile (query_hdl, &qio, &fpli, + sizeof (fpli), FilePipeLocalInformation))) + len1 >>= 1; + else + { + fpli.WriteQuotaAvailable = fpli.InboundQuota + - fpli.ReadDataAvailable; + if (len1 > fpli.WriteQuotaAvailable + && fpli.WriteQuotaAvailable > 0) + len1 = fpli.InboundQuota - fpli.ReadDataAvailable; + else + break; + } + } if (evt && status == STATUS_PENDING) { waitret = cygwait (evt); @@ -378,7 +400,7 @@ fhandler_pipe::raw_write (const void *ptr, size_t len) /* NtWriteFile returns success with # of bytes written == 0 if writing on a non-blocking pipe fails because the pipe buffer doesn't have sufficient space. */ - if (nbytes_now == 0) + if (nbytes_now == 0 && nbytes == 0) set_errno (EAGAIN); ptr = ((char *) ptr) + chunk; nbytes += nbytes_now;