From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20723.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::723]) by sourceware.org (Postfix) with ESMTPS id AF35D3857001 for ; Thu, 2 Sep 2021 20:19:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AF35D3857001 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=EcRQf+yPAcBMwgNbKLmTbgd7s9/7LmgcJpYqUoBB7oteP/EYcDBYAyP2wqLNfBB4gOwKc+nufyHdJM5+ewzd2jp7Px1R9wJLm0L9tU08D3b2Euacboj/IswZy0flEoeONsB7oMdxrscb9MuYwS6JHKKX/rNyeo/dAWJ0B8zS6ceVS5TjmpLyPXpUV8ChYXpO6B/rOeFZakAgyz3UPOfFEWH8nvAYTpzpc4FMd+pu7+itzZoMM2OLNzAX/haiqmtqchn3iyA/4bLZoJC2gxWErCPdMqSCk+XDEQPgUN91uvxSbwROc9Ddi1DvNQO3vRa+MyE9QwNKPQnaeErrGrLIBA== 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=5OelFtqII7lLf8e8d4ypjLXoolKliir2+kfg4AaUOu0=; b=RVWSvEow6cVtGCexKzhYoAeoJtQWI1WRXVxGnDaIJ47nDD8TphEPv3ZtMT9XVb3N23XIlhIHmCHuvb0CYoO9GnVFGZKk+/tWaqGgETugo01x6qZCO7E2dMYfSbwO4aFZwgKqBGJZ8jk2+0znJ7rYBOJhjN7rAL6KrybQpNPg5mrZmeRaihPOzldmTETC+iZP+7OCEKE7V2fw3tzQg5aWUDtjscgzUpAa84TeA+3VMU4oozJdV0frnlxWNS0RmBxVCwDyM7I6+XbidQqP9RuBEOywJEaMohqPigTj2AzEn0GsZ/TZvk1Gllzsp6nxJCLRUxIzchiuV/d4supArj9kxQ== 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=5OelFtqII7lLf8e8d4ypjLXoolKliir2+kfg4AaUOu0=; b=bk70hDgA0rO9Lq5BmUviMn3HLLKs/invZg0lpjHoOpGXUADXUW/OMQ213EUpcoQC8uefE5w6Qz0UA6X60JzcDuVbXIjoXR4Ah3zdvsBpn4YVgqgZ1CzEPEixUTERCaHqpKUsjZcfrYaxdMkr0ZJPeuKstekoks+7I5no9uSRIV8= 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 BN7PR04MB5299.namprd04.prod.outlook.com (2603:10b6:408:3f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Thu, 2 Sep 2021 20:19:07 +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.020; Thu, 2 Sep 2021 20:19:07 +0000 Subject: Re: cygrunsrv + sshd + rsync = 20 times too slow -- throttled? To: cygwin-developers@cygwin.com References: <20210901091652.6bf3cccbcaed4a22f6ffa6b0@nifty.ne.jp> <20210901172339.1039604b7067e0492534a20f@nifty.ne.jp> <24138e20-aa97-cfea-bf48-198fc67755ea@cornell.edu> <9ba687eb-f4a0-18f8-b10b-76e7e51e123e@cornell.edu> <152bfc0c-2f72-c684-6fc5-aa7c36c136b8@cornell.edu> From: Ken Brown Message-ID: Date: Thu, 2 Sep 2021 16:19:04 -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: 7bit X-ClientProxiedBy: CH0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:610:cd::19) To BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) MIME-Version: 1.0 Received: from [IPv6:2603:7081:7e3f:3419:3d1d:1494:5af9:3061] (2603:7081:7e3f:3419:3d1d:1494:5af9:3061) by CH0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:610:cd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20 via Frontend Transport; Thu, 2 Sep 2021 20:19:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf3e0868-438d-454d-29fe-08d96e4eea7b X-MS-TrafficTypeDiagnostic: BN7PR04MB5299: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N+sUUi2IR2WCk78VuCz2wfbs4Qu4TgGH1TXlAEtY/VkrPWiX7VLRHjsY6//NHREdMrs2bXRHlfbD8shslPObXb+yJptu1K1snuVbmnArbcm0T8MPcxyOZQ7FfG5NCGSBpRM0a556QGNoRtvbgzIoAYHIqEvUHY+fWIhcIPIvHVBpibk1HVeUV9h5VqMeD4EfITe7uJoVq2rMWd/ACQ3PWDT2YJHsA0RNxI/VPAkIx8LSZTqK4wmQXGjC97llwiHPtSfxB/S0VNyNLX3DNPrmRlN+bnCu6l72+GeVOA2XCqiD+45Nc09bXZ2QMq73uIhgsksm9lRPOm9xzphRiNHAmDmFQeTvLPNR7O4DilcE2maUoo62kuU55V/oLWmeseSO5olSsW/b53nt/tLeyhojC8DgGxLsMDcrgHvwfB0+dRAiXdeXV+fjCmkTLaVtSKJPs91rBPWIxMt5OwWRVSf9bsYVP4SVRaNz0/Ju9Aj0mHRtjgr6Arsu7dfowo3TG8tItux9dzwkshtgtVX2naMPEK1FLlV5jhIV6Wz5Ij7aYEJKDvHoWciPvx8DLWz10ByOmtuFkHa1QWlnd3Bguv7LSZ5HgfTTTFx4RJtMeRUGq66XAMLGrT7pIZ1y4T5uAEvsEsdZe/EG0Jre6fykZz3Wo3jGoc591nGWy7P+ICNjeQjEjQroj5wFN5C1LaLWzgRj3EDDJnvbb9xOuy1+d9EmPhhyT7dlD1tl1OZTXpho5Lc= 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)(366004)(8936002)(2616005)(6916009)(5660300002)(8676002)(6486002)(66946007)(66476007)(36756003)(66556008)(31686004)(86362001)(31696002)(316002)(2906002)(38100700002)(75432002)(508600001)(53546011)(83380400001)(186003)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?Windows-1252?Q?aRvZCpnua8+q4w+LpyrAD2E7xl6M7kfKId/32YE5m3llcESIki+bHAIS?= =?Windows-1252?Q?+iWEsPOMnr+8ROg60AeJpd/Ia/OFEjAPk3PoAOALlN9PGiwx/tfKHRQe?= =?Windows-1252?Q?kP/bi0k/RB63nJgsquqW4scsh7Dzru03ZJU9Xp4XDfBBcOgfwhkRZq2L?= =?Windows-1252?Q?nOqLtly2NC8g5E6vEdqc34mLcAWXMmUoYZzlACAO9RHgWXn1ZjTF9mYf?= =?Windows-1252?Q?IhIRzHtKrJLkof+BiLnfiwTH4IZaIOcgwTz65T92+bHy1nJOSa3TccEq?= =?Windows-1252?Q?ra88knjkWbyKe58WR+D7Pcoaz/blCHnENYlXIa9jqTuUnB0IWn4oPryz?= =?Windows-1252?Q?qw1X9oiZXYTXLY3QAy7/jiHPDvTHd40CgYvY158tYQKgqeDbLUGVqUtG?= =?Windows-1252?Q?z0U6IhZCsZ/RVfdrlsIdIPvMwRKCE9+BncOGKtOdjpJDq++sr/tq+b+5?= =?Windows-1252?Q?M9l9Eb36R/TJ4MrBF7thZQbVEHd2evygndWK7YIa7+9UAOiKvg60QO7Q?= =?Windows-1252?Q?LkylXIhJAJcNp//3BEl4RAeEtcMmSm9sUaiOKPPjxl9m9RXhCkaiFeYG?= =?Windows-1252?Q?gXzz0skQtK9xEDGEFURmWAC+/VZ2bLjf4FwLo1DzwWtb3iXA9zynSiUe?= =?Windows-1252?Q?G5YQgD3KrFJSlVKq25fuv0kQwghqh2T7LuE6WCO87987D/13lYVISyeo?= =?Windows-1252?Q?UTEN4J2mIZ48/HEbRyT8xu99kncTS0v296gERL9yXUy1ZuaPU+M6HMtB?= =?Windows-1252?Q?TOsUmZ1l6ZWoWPh8RdC1LnOLyu+a2jVh/ZjvnpY3bOrRqhjfAbD8+JXg?= =?Windows-1252?Q?HfmTljosbBcq05kDVbWRfKL4rmzVypYC0D+CgjEHnOhZQtx+811QPG97?= =?Windows-1252?Q?Z4bNtSkJYmmARx6AsuKX5jq93rDhzPPF2u0hIJHftJVn32c2ZBV01t+5?= =?Windows-1252?Q?B3iTCsGpPWOejvKlyNSvlT7cpRVaAHoVUWqbsTBmgUWRw5LTED+s61sJ?= =?Windows-1252?Q?Kww656vPLp1FdXY52wBz+h06xPClmzvgIggDhlRmMTa29ctx7vojXIbT?= =?Windows-1252?Q?iowd9TByYZw42NuAoZglyU6xzQSh/pvKcwlyCnWSC7q6UJA6cyyARc2a?= =?Windows-1252?Q?4EuSPssciODkFOFmoThVOBHpETCbEhnF9L9yynZfiNQSF8FX9cIkpC/y?= =?Windows-1252?Q?CQz0cwr8iilxIg+CYdjDJM6zLOs9ylSgSYrqDstixJjGpXdJBCVPAOZG?= =?Windows-1252?Q?ddEH1e9SqPp1kX+7gWEuRXzHZ1+G76TiDS56yihQc3xeDPjMalta0WXY?= =?Windows-1252?Q?x4czR8hgDErOFEiFsqnSDj7dI0fWFO8Hw4dMgTVhZY7FlqrpYLmg6i1J?= =?Windows-1252?Q?mWXU4bySTj3WJMwGNYE84BV9V4E9D+LomYhKw52LXRuRxJwL7wIs9dvQ?= =?Windows-1252?Q?jP0Hz7VkNsclnbd7nwQ93v8DaXvpVgu2aX/KJ7V74bbFgpI3G/cDsrHB?= =?Windows-1252?Q?xFbVf5QC?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: bf3e0868-438d-454d-29fe-08d96e4eea7b X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2021 20:19:07.1999 (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: J4AP/jaIIqKqsmz5ZrYoEPfKnQWbRDCj/CUiIWjYyG+mqTv4t75A4whGzfX2K0kRgn2qzLR9NWIYUs23JB0uGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR04MB5299 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, 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: Thu, 02 Sep 2021 20:19:13 -0000 On 9/2/2021 3:35 PM, Corinna Vinschen wrote: > On Sep 2 21:00, Corinna Vinschen wrote: >> On Sep 2 09:01, Ken Brown wrote: >>> On 9/2/2021 4:17 AM, Corinna Vinschen wrote: >>>> What if the readers never request more than, say, 50 or even 25% of the >>>> available buffer space? Our buffer is 64K and there's no guarantee that >>>> any read > PIPE_BUF (== 4K) is atomic anyway. This can work without >>>> having to check the other side of the pipe. Something like this, >>>> ignoring border cases: >>>> >>>> pipe::create() >>>> { >>>> [...] >>>> mutex = CreateMutex(); >>>> } >>>> >>>> pipe::raw_read(char *buf, size_t num_requested) >>>> { >>>> if (blocking) >>>> { >>>> WFSO(mutex); >>>> NtQueryInformationFile(FilePipeLocalInformation); >>>> if (!fpli.ReadDataAvailable >>>> && num_requested > fpli.InboundQuota / 4) >>>> num_requested = fpli.InboundQuota / 4; >>>> NtReadFile(pipe, buf, num_requested); >>>> ReleaseMutex(mutex); >>>> } >>>> } >>>> >>>> It's not entirely foolproof, but it should fix 99% of the cases. >>> >>> I like it! >>> >>> Do you think there's anything we can or should do to avoid a deadlock in the >>> rare cases where this fails? The only thing I can think of immediately is >>> to always impose a timeout if select is called with infinite timeout on the >>> write side of a pipe, after which we report that the pipe is write ready. >>> After all, we've lived since 2008 with a bug that caused select to *always* >>> report write ready. >> >> Indeed. Hmm. What timeout are you thinking of? Seconds? Minutes? >> >>> Alternatively, we could just wait and see if there's an actual use case in >>> which someone encounters a deadlock. >> >> Or that. Fixing up select isn't too hard in that case, I guess. > > It's getting too late again. I drop off for tonight, but I attached > my POC code I have so far. It also adds the snippets from my previous > patch which fixes stuff Takashi found during testing. It also fixes > something which looks like a bug in raw_write: > > - ptr = ((char *) ptr) + chunk; > + ptr = ((char *) ptr) + nbytes_now; > > Incrementing ptr by chunk bytes while only nbytes_now have been written > looks incorrect. Yes. I actually copied that bug from fhandler_base_overlapped::raw_write. It's amazing that no one has no one has bumped into it up to now. > As for the reader, it makes the # of bytes to read dependent on the > number of reader handles. I don't know if that's such a bright idea, > but this can be changed easily. > > Anyway, this runs all my testcases successfully but they are anything > but thorough. > > Patch relativ to topic/pipe attached. Would you both mind to take a > scrutinizing look? Will do. Ken