From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2110.outbound.protection.outlook.com [40.107.100.110]) by sourceware.org (Postfix) with ESMTPS id BEFF03858417 for ; Mon, 30 Aug 2021 13:36:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BEFF03858417 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cornell.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cornell.edu ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Taz0eLuaUjRhFtDxusW8HSJHpnxM88NKZQx1r63zVo4AykF46IblxH7wA5BJ/GvnGzYWpwIhCKiutQ+OuAEQhvmgWDE9f0Y1v9GfX3u6RwK8nGEZjwc1OoNTTfjp7x/L4wayuIY/X8xFCiXH2c/aZKcStuiDwl+WJQlgxM+XklzCDcy6G9OU/vBFEyH10+LR5FG8xcrAN3Wl2zwRmGLRJjsu2l0o9Yfnc2x8WNQGBnTiFBVVUbHk6vaEBsux0sVc1igLqAFG+1qif7sA7+pmJoUvPGL+HgMnoSZyEbbV3QApcBuGvdS1rYU7UWJPN6fWECMojD5qQ48hB+pb0+zeZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5VTLI8mdwldg+NdQDOjkaQs2djGpCvLxc3/R8jKc7YQ=; b=kRu21Ioanmoqd/ulOrpE3nuJOBRdizDnte52KBibL/SnWD5r6lD2kb5Gt3twPTw5HEtkuULIc6tZe6EUjMYz5qBKhaaRWyNdW/XmGsokEhnPlwS1+rm+vVGw4MnIQlwwzn+Uuoq1nLzKnTC9HPYmDWE5TEWvuROOwSZeTlV4EFixqs58sjZRQp2OJ+01I6uKcw9IncLFyv0XE0yE8t5OSBger0TN1zVX9Cj4QaQAWNC6WTDCtN5djhUmDP/pp8kS0TvWuNk2NUxJCmKjgYDHvplPdlarUfqVZX6BAtYF5GhOHZQCLil1ojzhnV5RvQYeA0bNf4hUQPzjp/tCEB1ZpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5VTLI8mdwldg+NdQDOjkaQs2djGpCvLxc3/R8jKc7YQ=; b=jR9w9NYidm4AxrMK0hIPupi/GQxsWHf9K2wHdCx9JFMh7oYgaVh6n45J7x/TgV3AFWx1I4af4KxVuO7VXrr8EMyK6Hdi29X1/3E+WRBXdqhvms6RtnGHqNQgQJIr7Sp7D2P5nwVvFEGVqRhuceDKjvgzPaIkskKH3jilB4TTiFw= Authentication-Results: cygwin.com; dkim=none (message not signed) header.d=none;cygwin.com; dmarc=none action=none header.from=cornell.edu; Received: from BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) by BN6PR04MB0659.namprd04.prod.outlook.com (2603:10b6:404:da::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.24; Mon, 30 Aug 2021 13:36:05 +0000 Received: from BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::38bd:b608:234f:9ec6]) by BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::38bd:b608:234f:9ec6%7]) with mapi id 15.20.4457.024; Mon, 30 Aug 2021 13:36:05 +0000 Subject: Re: cygrunsrv + sshd + rsync = 20 times too slow -- throttled? To: cygwin-devel 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> <20210830092259.52f7d54fc3fa340738373af4@nifty.ne.jp> From: Ken Brown Message-ID: <529d7dd7-d876-ca51-cc1f-e414d3c24f71@cornell.edu> Date: Mon, 30 Aug 2021 09:36:03 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: CH2PR18CA0043.namprd18.prod.outlook.com (2603:10b6:610:55::23) To BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.211] (74.69.128.111) by CH2PR18CA0043.namprd18.prod.outlook.com (2603:10b6:610:55::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.20 via Frontend Transport; Mon, 30 Aug 2021 13:36:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 65b066c0-109d-422a-9948-08d96bbb1d7b X-MS-TrafficTypeDiagnostic: BN6PR04MB0659: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:529; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DZ73vDvn2JlBbMWBJ0cHcOXf9RVyMJsGiZjr/DvPRhvnSA5MDx6xPnn1goohTIGOk6oHOrqaqoJdWdwJn8JB3PuZPwNc3lmJKeNBSfIAngTeF6oFbbvESzNBKLA3gk01uiw4NKZM2wwfjHS2DJRWZSEQydgTQl5z9LMs8p5uMC8OZ17XE2o/Sud7roL3q4BGnKJ8HxI7n5IHRdkXKwS8Bk7Od83f9ggdbevJmrKoJaRHBhtbnwAZggIFrOT6ViQQCG7po8OPrmxnia8UFlYg5og9fNEXy2cuWmVnt+kAgG5P/vI8vzCXMhDI770Eg/Y8r11JNhLRqFBVDLR4NtMPSsdQi1J7LmCFaBNez19JLLz/42N0OfhowGG9o6Axnju9Px5xf2sSYcIhEz3yoOwxAzfSWwWtwadyR899hoD+untIC0qDOuyuDLstHaimekjQok/jUx86ZDF1hXCPKUUHyGokSeKxZ2O9X8+Wls1O9RHWah9F2Gjo2qLW4U4IUBw4gRw7GRYTo5nHdilveH3ckmPl1c9oTi0fHk6cQ01TdWqH30I4w58qyV72tKPF1cLHTOimnW7pFR9IhxAvR95ej2pqzx8Ba9Qe1zswN3sPdpD21opwbSbDBk61HOuOLtCbjIyLDPC+bF/Ztx+jlNmxql91K0zzKRCG9usIuisfjakW3MHRPMgLtarOwfwKOaeIVIxhqkPIhx5JtII0DosB7DF/IEEC6sOakimYNc3TccrEkwF4+bm+IkxuW3vZ+doIWauLqB16PXH8AldwoYMn9jV25C5BklrWOnKIl1TIBQiwfRl42r0sJLEK1rmhvbQV X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN7PR04MB4388.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(136003)(346002)(396003)(366004)(83380400001)(966005)(6916009)(8936002)(36756003)(38100700002)(8676002)(75432002)(2616005)(956004)(6486002)(86362001)(31686004)(66476007)(186003)(316002)(31696002)(66946007)(26005)(5660300002)(786003)(2906002)(478600001)(16576012)(66556008)(53546011)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?Windows-1252?Q?atvffLW4OUyyM7YcL4nIhVJP/yupn6sM2WScBohMQahLmU5tQk9pb0kY?= =?Windows-1252?Q?Q3pTC+XK9Yn/+tVDgBwEDE2IKJ8ag+yGUNlCamE3Srh/uJ/Nh3qSvlSd?= =?Windows-1252?Q?cbM8JCLazQFIFenbXsjNpFdCV2HPsBXxxY0nmBHnwsA/AE3DnLdxIQAf?= =?Windows-1252?Q?OtF7y8KNNKrW0YWwEN8rX+DMOdwrhfgT6zWokfEmSk3OqMbX8Wj+XmLs?= =?Windows-1252?Q?L/QF3eQ6WJsZFL+WKZUQ7lHtYsSeLHdMWa0oc+TiOrTt+nCxComDghJ6?= =?Windows-1252?Q?udMqHbpNW6YKWXxaBrZ/iyd3w1mneqt4J7D0t7Yc9svWRap7C/OmX6jy?= =?Windows-1252?Q?UuSZBTRfT6XFzlfghzI/4TEDvM1Bi/HNpO1BltGTc9qYcdJgJ8PbnsJQ?= =?Windows-1252?Q?guRCsmJnqzQvfWd1YrIPmBtNZIfAuE2jkrcCXV/PFUivEBolFxJxZoqx?= =?Windows-1252?Q?dFMLRTIoDZ3vhy2dfBhbzZcKJa5pIz4ERDbI2LD/vX+/5awg7oOxs2yP?= =?Windows-1252?Q?wMqPiMYxmYRF74+5N6fLf9QDCe94Voa3CY3sYFp4FhnJIRGWJJMlDqij?= =?Windows-1252?Q?+Fdj+HHnsBxgV7VLx5CJAj/2o2SL/7GUcJsWdKP+mhIt+1Wr+6CAdjMp?= =?Windows-1252?Q?CIHBpPj02iUw9Ssce1dGGDv3sumB8DXaNjnJkCuuT7V3bQMMOLv5Svbs?= =?Windows-1252?Q?CmPJHXkRmlKuol4ssB4ocRjRQqrgHuNvM3C7shhpbTzfgTnRGVcOSDT/?= =?Windows-1252?Q?t37W13TkKGDNlk83VETmNgZswomIqaFiutZyxNa0x9pBBilpMENVYx3d?= =?Windows-1252?Q?K4RKzOwu9MQq84UuODLy+nur+lhtqC/NnPLRYrjzd2fhio1JqdwmVExj?= =?Windows-1252?Q?hqXXLtDRdOlzpwGcTCpI4lEFfbv7258MK/S6iQm3ieG57Q+wvPonmkkw?= =?Windows-1252?Q?SOfPTADHdqPMypGBgcFwJhQQQAxvuMM2tgDLQw1yAsXTt2litrKgIlif?= =?Windows-1252?Q?PcyXf5SELOolE2IGU9YRruaMVW2zAXYAU8qDyXXWdtixDSHJ2gE+4L+O?= =?Windows-1252?Q?T/izESsr+kwkaQt1TQRn8i/i+39YS3vJo4uby+rBp5c8d2YclqN4dY9k?= =?Windows-1252?Q?flcxrjSIsyFB9q7xa4QTY6xeYLheaJeEf6xcdPN/Q0Z7K5n0v5X7HHXv?= =?Windows-1252?Q?YT2/K8p2DhOmEfvkDaKIo01hprQpgquSqbsAshV9skVNC/xoyrVB5ari?= =?Windows-1252?Q?Uj3bmPjoFQWlNJOOgG/qzavX/1vWoj4Enfdi8EH8cnfrxBNnviOwtooX?= =?Windows-1252?Q?lYZehvb6IN3SjgEfYxjVx/ZcbFuUB04x2TtCzKQn6oZXJiyRfOgXcW5s?= =?Windows-1252?Q?yhUXF1CHkcUarMBenhJRSR8LFE8mOHKoeABIyoRvvKdZ9uKl9z3kGA5T?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 65b066c0-109d-422a-9948-08d96bbb1d7b X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2021 13:36:05.0270 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3vVSnomHtvE8CfmRDkewZrxq9KDzb9CDxOQAIgmTv/sH3PdG6ZRCZTgpAuOJ+s5Ec8iRW7SlQ/fdnh/+Oxul2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR04MB0659 X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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-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: Mon, 30 Aug 2021 13:36:18 -0000 On 8/29/2021 10:15 PM, Ken Brown via Cygwin wrote: > On 8/29/2021 8:22 PM, Takashi Yano via Cygwin wrote: >> 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. > > I vote for 2), but let's see what Corinna thinks. > >> 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, >> > > I agree. Now I'm starting to wonder. The use of fpli.OutboundQuota - fpli.ReadDataAvailable instead of fpli.WriteQuotaAvailable was introduced in commit a010e6abe, with no comment in the commit message or the code to explain why. Corinna, does this make sense to you? Is it related to the issues raised in the message https://cygwin.com/pipermail/cygwin-patches/2004q4/005002.html that you cited elsewhere in this thread? BTW, when I was working on the pipe approach to AF_UNIX sockets (topic/af_unix branch), I had occasion to step through select.cc:pipe_data_available in gdb, and the use of fpli.OutboundQuota - fpli.ReadDataAvailable definitely seemed wrong to me. So when I wrote peek_socket_unix on that branch, I used fpli.WriteQuotaAvailable, as Takashi is suggesting now. Ken