From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-04.nifty.com (conssluserg-04.nifty.com [210.131.2.83]) by sourceware.org (Postfix) with ESMTPS id AC2BC3858C3B for ; Mon, 30 Aug 2021 00:23:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AC2BC3858C3B Received: from Express5800-S70 (z221123.dynamic.ppp.asahi-net.or.jp [110.4.221.123]) (authenticated) by conssluserg-04.nifty.com with ESMTP id 17U0Mp92028626 for ; Mon, 30 Aug 2021 09:22:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com 17U0Mp92028626 X-Nifty-SrcIP: [110.4.221.123] Date: Mon, 30 Aug 2021 09:22:59 +0900 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: cygrunsrv + sshd + rsync = 20 times too slow -- throttled? Message-Id: <20210830092259.52f7d54fc3fa340738373af4@nifty.ne.jp> In-Reply-To: <20210830091314.f9a2cb71794d0f68cdb5eba7@nifty.ne.jp> References: <41A583E1-C8E7-42AB-9F24-EEC33A41EC60@house.org> <20210825201845.07b6400b79dc5558a7761efe@nifty.ne.jp> <20210826062934.54f2f2216021c095bb7ba13b@nifty.ne.jp> <3b560051-ab27-f392-ca4b-d1fd9b5733b0@cornell.edu> <20210827202440.47706fc2fc07c5e9a1bc0047@nifty.ne.jp> <4f2cb5f3-ce9c-c617-f65f-841a5eca096e@cornell.edu> <20210828022111.91ef5b4ff24f6da9fadb489e@nifty.ne.jp> <20210828184102.f2206a8a9e5fe5cf24bf5e45@nifty.ne.jp> <20210829180729.48b4e877f773cb3980c5766d@nifty.ne.jp> <20210830091314.f9a2cb71794d0f68cdb5eba7@nifty.ne.jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2021 00:23:30 -0000 On Mon, 30 Aug 2021 09:13:14 +0900 Takashi Yano wrote: > On Sun, 29 Aug 2021 17:04:56 -0400 > Ken Brown wrote: > > On 8/29/2021 5:07 AM, Takashi Yano via Cygwin wrote: > > > On Sat, 28 Aug 2021 18:41:02 +0900 > > > Takashi Yano wrote: > > >> On Sat, 28 Aug 2021 10:43:27 +0200 > > >> Corinna Vinschen wrote: > > >>> On Aug 28 02:21, Takashi Yano via Cygwin wrote: > > >>>> On Fri, 27 Aug 2021 12:00:50 -0400 > > >>>> Ken Brown wrote: > > >>>>> Two years ago I thought I needed nt_create to avoid problems when calling > > >>>>> set_pipe_non_blocking. Are you saying that's not an issue? Is > > >>>>> set_pipe_non_blocking unnecessary? Is that the point of your modification to > > >>>>> raw_read? > > >>>> > > >>>> Yes. Instead of making windows read function itself non-blocking, > > >>>> it is possible to check if the pipe can be read before read using > > >>>> PeekNamedPipe(). If the pipe cannot be read right now, EAGAIN is > > >>>> returned. > > >>> > > >>> The problem is this: > > >>> > > >>> if (PeekNamedPipe()) > > >>> ReadFile(blocking); > > >>> > > >>> is not atomic. I. e., if PeekNamedPipe succeeds, nothing keeps another > > >>> thread from draining the pipe between the PeekNamedPipe and the ReadFile > > >>> call. And as soon as ReadFile runs, it hangs indefinitely and we can't > > >>> stop it via a signal. > > >> > > >> Hmm, you are right. Mutex guard seems to be necessary like pty code > > >> if we go this way. > > > > > > I have found that set_pipe_non_blocking() succeeds for both read and > > > write pipes if the write pipe is created by CreateNamedPipe() and the > > > read pipe is created by CreateFile() contrary to the current create() > > > code. Therefore, not only nt_create() but also PeekNamedPipe() become > > > unnecessary. > > > > > > Please see the revised patch attached. > > > > I haven't had a chance to test this myself yet, but occurs to me that we might > > have a different problem after this patch: Does the write handle that we get > > from CreateNamedPipe() have FILE_READ_ATTRIBUTES access? > > I have just checked this, and the answer is "No". Due to this problem, > NtQueryInformationFile() call in select() fails on the write pipe. > > It seems that we need more consideration... We have two easy options: 1) Configure the pipe with PIPE_ACCESS_DUPLEX. 2) Use nt_create() again and forget C# program issue. Even without this problem, select() for writing pipe has a bug and does not wrok as expected. The following patch seems to be needed. diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 83e1c00e0..ac2fd227e 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -612,7 +612,6 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing) that. This means that a pipe could still block since you could be trying to write more to the pipe than is available in the buffer but that is the hazard of select(). */ - fpli.WriteQuotaAvailable = fpli.OutboundQuota - fpli.ReadDataAvailable; if (fpli.WriteQuotaAvailable > 0) { paranoid_printf ("fd %d, %s, write: size %u, avail %u", fd, -- Takashi Yano