From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2104.outbound.protection.outlook.com [40.107.237.104]) by sourceware.org (Postfix) with ESMTPS id DFC223858421 for ; Sat, 4 Sep 2021 14:04:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DFC223858421 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=E5MoWdAyy/RHSS4fzQ+1KAArNsVIB9r/F7oUNNfeEXtzKI8OCChdfynvHa4N7EV+zyx/4dGVUjWaSx6Y4ngQoUOmP04qRAI/Eqc0Gxl8XLYoYIjcj9UwdFyMRZELZQMkPh3QveXZ2Ujyi6mYQ37ydAirmxwXcOCC5qTB1kuCEAmljSz+feIffLhoqvvtgQayMLpNAO0FGbz8BxkSD77SaEenhXmdtHLQcJITtK22w/c6z9U+or3eL3cRDse3EkZLftKq86j0cWsX/HCSbJu2yKWS0GvhDCydL3Kj3kar86NMIA/U0e0EpK+mDN6YwuYFjaLviIekiLai+oryhXh7cQ== 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; bh=Bk64TUGBaesjJMdsRGoBV8b2QfHMla/LYj1hebCEdqA=; b=Tk7oHvHoLaObh6yukDnayv5m92r3OJTkc4sneutjZkHYogOzoe2CtFQAYshdyf56vlSjGdjBdcgGsne6kxM29rKYDns3Nl5VMj9rngj1ejKPSRadmK5HH8airlvRFxaPv68zmBpCWZUX7MRLoYmn0szqZVeAVhZK3sWhJU5A5A6QN/vpTmtQHEcuX++3Ksi0m+wYb+Wh4NflT4UyFgam8/pkrOWUKqtokApFfbpO/8zxZr0Po/70b64AfiWDdrhwVcTpKpMcQNf1KXryxBSVu9CX2Q5MZ7Clcbm6gSO7Qrb6n89WvUSttibjP8ONIjW0QA96ZQ4uTRJOvIVrVs4JHA== 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=Bk64TUGBaesjJMdsRGoBV8b2QfHMla/LYj1hebCEdqA=; b=cubCeA6fSt/EhBNyN08iDx+u5jgAk2AUbXjvNXW98Hqt0alkZDtW4QLXF/YXLDOYp6AoRuf9VKeYSdtQe4byGJuBTYX2Q1bp3923H+1HBk7vDcqJ6DEzk8vLW0wPQQHF6z+Gx4juMavP6cl8L0ZVqXhJm2y0o/dS5ibbyAkpGq8= 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 BN6PR04MB0707.namprd04.prod.outlook.com (2603:10b6:404:d2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.22; Sat, 4 Sep 2021 14:04:13 +0000 Received: from BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::b510:889b:1fd0:d80e]) by BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::b510:889b:1fd0:d80e%7]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 14:04:13 +0000 Subject: Re: cygrunsrv + sshd + rsync = 20 times too slow -- throttled? To: cygwin-developers@cygwin.com References: <9ba687eb-f4a0-18f8-b10b-76e7e51e123e@cornell.edu> <152bfc0c-2f72-c684-6fc5-aa7c36c136b8@cornell.edu> <20210903190046.663c60fb11c936e344821383@nifty.ne.jp> <20210903191340.c28ae366e79ca14799bacc1f@nifty.ne.jp> <20210903212205.acc2fc68cc4ffce9c1db3dd9@nifty.ne.jp> <20210904210258.342eb795ac53f1d5352ea512@nifty.ne.jp> <20210904213713.8760e7ba3a4d68fbb78d677e@nifty.ne.jp> From: Ken Brown Message-ID: <51cb0cef-c3fd-1320-c2dd-a868bf1ffaae@cornell.edu> Date: Sat, 4 Sep 2021 10:04:12 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: <20210904213713.8760e7ba3a4d68fbb78d677e@nifty.ne.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH0PR08CA0010.namprd08.prod.outlook.com (2603:10b6:610:33::15) To BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) MIME-Version: 1.0 Received: from [IPv6:2603:7081:7e3f:3419:4172:b7ad:cdf5:53cb] (2603:7081:7e3f:3419:4172:b7ad:cdf5:53cb) by CH0PR08CA0010.namprd08.prod.outlook.com (2603:10b6:610:33::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Sat, 4 Sep 2021 14:04:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6fccb59c-5b27-4aed-57cb-08d96facdfb6 X-MS-TrafficTypeDiagnostic: BN6PR04MB0707: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r2Xa3aFDjeqVHuv4wzbyR2pjgX8upbsMQ+xQ0qAHs/m4EB2EOXfrYzWqvV4shZKfVSf+A583e+R/GDlYdtYiih8QRoEtP6G7JvIj9WOODSs6JqEmRx3MGFld3WVTCNt16/mt9hVXmfdNB+HMStmGUNtuYnhdJ+M4sdbwZgEvn6gSiJJJMllPW7t5aJoC+MkLlPa8Qu2rZIJukxD0MbWiEBA6aOVqrehp3gV+eNIaf0CwyT0X2TKWoy1Zx0jsZkRlj5KTSNlIEPdasK7BQU2k6JGmLqqX2SIk4s2J38dLnC/eSOq7Sx5PfXjSEXF8M6jgaGpU1pJzi40GzY+yxvEOiHHGNiPbvos/1V3P54L08jxcoL/U4EMGQbszi0WWqfdtqUXcpUR5JRgsYOb+A+He+I9NxrDqNQXEWiND8OGyb/qka8esccaU6M5ldak+M1/JKlgBfxUneNkWAjLSfhJ1AxgeGNYnDv1d2ZUvLlStYMaCKbgr1livS35krHjEHh2k97aRdxrPbvO8kT3HqzfnJpqD61H8p3cD3q4OLVpE6szGNjLp8i4vi1Lrihu1OgriOsrKS3HA9k5qR/D6K7spA823Rf0g6E9mewtZDnsYeyFzZW6eUuK2EP9WLVAa1ns6A36xldObna9PXzldTfxFf1MKoIDyVx4I1gAT37dZCeX2MX6Wzpc+jhqwq5zt/9m+xKn2fqp9dnLHFIntvwOinvCXIH2nhjD0FppeDWEZpOYWvNyAu+MdUWo+6Ltt5v4KY495in1VpsJlceISEDH8QSMJI8k+jRLBhv1+S5pUxDWMmipNhtAsro8gSO9JNHjD 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)(396003)(136003)(366004)(39860400002)(346002)(2616005)(5660300002)(66476007)(66556008)(66946007)(186003)(31696002)(8676002)(38100700002)(478600001)(2906002)(86362001)(6486002)(31686004)(8936002)(53546011)(75432002)(966005)(316002)(83380400001)(6916009)(36756003)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?Windows-1252?Q?5RuvbAhzpn89OkgDdFjPebYfqUd/+hnWn7wTu6VpDcsz9LaKe0q44t38?= =?Windows-1252?Q?YcHhkJkTbb4VFLyrhkBtpW+Upgs7BdIDya3BqTKZyphBtw0JC47FAN7t?= =?Windows-1252?Q?Tk8fpXRb9Xt31KY5fCkLPcgqk2qLZLx9hTAhbtOcKNSEpTOzDrsNNvGE?= =?Windows-1252?Q?EJ5LxqwX0BblebzwKKtGnhmmOZAM5CpeXBbRXESaiag/TAr0s8/HxWbJ?= =?Windows-1252?Q?s3V2YLH9MwYlzY0x0/UdS45BMFlrDRjM+AVFjTb8aNRmhVxN/R/6yus2?= =?Windows-1252?Q?uPbjX+Xt7UgjsVu83KfpM4PlHNLuaAcjco8W/COPTUzt2N0HGjWDFfH2?= =?Windows-1252?Q?yplT0fEbqZOH6eo8YCRUmnhOndfAT11SYr11c+ZJS6QfO7o6FuF832Fg?= =?Windows-1252?Q?7SFDF73Ngsnc4rwBAEf5kmZ2nh9PiGmo5iR3CcFUGzRE4txbzt7Bhef9?= =?Windows-1252?Q?KuWHCH40XCEkmkawOoRiqsASFFj7FapFfTyQXOuD6JKKHvu9RAcP7WKt?= =?Windows-1252?Q?EFB8sNYNThcWzc82a9GM/cr0yx8QDK1/MgMNd1G4ucU41PkVaPAxW4LR?= =?Windows-1252?Q?TwWBs900y6vcP1Qv+6LnHgdX8zFZYwl103Xx8sjRwBptRd1F7fKcHagT?= =?Windows-1252?Q?40SzpPXJk/0AYNGR7kYdB7pCdF4hy5tHFHICNTWMGsbr47PjtIAIf1om?= =?Windows-1252?Q?ibmyaolnrDY1WYtfPotoi+S1rykw1Yk+87mrRCUSJNa7LIBtWKU4zTab?= =?Windows-1252?Q?bzZ+aWlZNORM175Vi7+P4tNOyO2bbHTkGbvaKQRkmaqJXRy+l8SUa0FS?= =?Windows-1252?Q?zG4jtzw1/xyPRMbxqF2pR89EwcxJ0xrEOwuyGlaFEAj2Cj6BFOh0Ydwx?= =?Windows-1252?Q?/3WcmevGdGqwjSnyQEzjm04bJhKN4cvx+Z+Gy9SEw7Mey9KC1PFExs6+?= =?Windows-1252?Q?kiozSjjnzJBGCWWxV6HQnuKIh6zoy037v74jwB0woesTTxs54hDGhvmk?= =?Windows-1252?Q?mgIEMo4Oefq8yz6Ci5DArFSx8TBzYgGP4Pt0DG7G93rHj4Gf/iA9nvCC?= =?Windows-1252?Q?f5hpKslLv/zH+68ez2xedflJohawuHV4K2SYPq16EGs4dzvVfV5zb8X2?= =?Windows-1252?Q?VqqxaNzwfH8guEFJSSUaoPz8XZvJ2W9HQS3Wpolz/pWBlruOOB/G16l2?= =?Windows-1252?Q?ugtyl09MRibk9chFNXgU0C5cSZ4E9lUeJCvbkx15v51XJUHdm4uXWQWM?= =?Windows-1252?Q?mxavvsGEzfS/w9Ak8DSlpbBfy6q4LCfCBP8zoKewWqzyOaRZmCB41ozG?= =?Windows-1252?Q?L5+71DQFoNjWsjmn9IVTyyPbZLkPb0J47LEVFf+m31ufQKCKL7uMVowp?= =?Windows-1252?Q?8eUaRq9R1L+/+Uzw/wBiG5a64iOoaBdGSRGp7f0GI7LMml5p5tPhNBfv?= =?Windows-1252?Q?czRB8LlBp2iPcK1inPTYrZMadkFc0SDlKTgr6oG5X6Wp/ZaSpa0Vog3w?= =?Windows-1252?Q?LKOF3Xj8?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 6fccb59c-5b27-4aed-57cb-08d96facdfb6 X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 14:04:13.0181 (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: 9JiFWs135EUwKq5gQtBhtg/F+b/lobY6b1wuZjBQzuZ8rM+XIj8MLmYy9rOc+qX8BVBAZuSL2eMLg2egcmwTiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR04MB0707 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: Sat, 04 Sep 2021 14:04:17 -0000 On 9/4/2021 8:37 AM, Takashi Yano wrote: > On Sat, 4 Sep 2021 21:02:58 +0900 > Takashi Yano wrote: >> Hi Corinna, Ken, >> >> On Fri, 3 Sep 2021 09:27:37 -0400 >> Ken Brown wrote: >>> On 9/3/2021 8:22 AM, Takashi Yano wrote: >>>> POSIX says: >>>> The value returned may be less than nbyte if the number of bytes left >>>> in the file is less than nbyte, if the read() request was interrupted >>>> by a signal, or if the file is a pipe or FIFO or special file and has >>>> ~~~ >>>> fewer than nbyte bytes immediately available for reading. >>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>>> >>>> https://pubs.opengroup.org/onlinepubs/009604599/functions/read.html >>>> >>>> If it is turned over, read() should read all data immediately available, >>>> I think. >>> >>> I understand the reasoning now, but I think your patch isn't quite right. As it >>> stands, if the call to NtQueryInformationFile fails but total_length != 0, >>> you're trying to read again without knowing that there's data in the pipe. >>> >>> Also, I think you need the following: >>> >>> diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc >>> index ef7823ae5..46bb96961 100644 >>> --- a/winsup/cygwin/fhandler_pipe.cc >>> +++ b/winsup/cygwin/fhandler_pipe.cc >>> @@ -348,8 +348,13 @@ fhandler_pipe::raw_read (void *ptr, size_t& len) >>> CloseHandle (evt); >>> if (status == STATUS_THREAD_SIGNALED) >>> { >>> - set_errno (EINTR); >>> - len = (size_t) -1; >>> + if (total_len == 0) >>> + { >>> + set_errno (EINTR); >>> + len = (size_t) -1; >>> + } >>> + else >>> + len = total_len; >>> } >>> else if (status == STATUS_THREAD_CANCELED) >>> pthread::static_cancel_self (); >> >> Thanks for your advice. I fixed the issue and attached new patch. >> >> On Fri, 3 Sep 2021 17:37:13 +0200 >> Corinna Vinschen wrote: >>> Hmm, I see the point, but we might have another problem with that. >>> >>> We can't keep the mutex while waiting on the pending read, and there >>> could be more than one pending read running at the time. if so, >>> chances are extremly high, that the data written to the buffer gets >>> split like this: >>> >>> reader 1 reader 2 >>> >>> calls read(65536) calls read(65536) >>> >>> calls NtReadFile(16384 bytes) >>> calls NtReadFile(16384 bytes) >>> >>> writer writes 65536 bytes >>> >>> wakes up and gets 16384 bytes >>> wakes up and gets 16384 bytes >>> gets the mutex, calls >>> NtReadFile(32768) which >>> returns immediately with >>> 32768 bytes added to the >>> caller's buffer. >>> >>> so the buffer returned to reader 1 is 49152 bytes, with 16384 bytes >>> missing in the middle of it, *without* the reader knowing about that >>> fact. If reader 1 gets the first 16384 bytes, the 16384 bytes have >>> been read in a single call, at least, so the byte order is not >>> unknowingly broken on the application level. >>> >>> Does that make sense? >> >> Why can't we keep the mutex while waiting on the pending read? >> If we can keep the mutex, the issue above mentioned does not >> happen, right? >> >> What about the patch attached? This keeps the mutex while read() >> but I do not see any defects so far. LGTM. If Corinna agrees, I have a couple of suggestions. 1. With this patch, we can no longer have more than one pending ReadFile. So there's no longer a need to count read handles, and the problem with select is completely fixed as long as the number of bytes requested is less than the pipe buffer size. 2. raw_read is now reading in chunks, like raw_write. For readability of the code, I think it would be better to make the two functions as similar as possible. For example, you could replace the do/while loop by a while(total_len