Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113047 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54895 invoked from network); 2 Feb 2021 03:21:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Feb 2021 03:21:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2FD1B1804CF for ; Mon, 1 Feb 2021 19:04:22 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10olkn2105.outbound.protection.outlook.com [40.92.41.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 1 Feb 2021 19:04:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=INgUKwFB8+gdWbF7VByG6n36pBX9cv3vPJUlXAeNL4R4BGUM6qLFr3y3ulOfx0L7IAihO7/O7b3SlhDSb8eOBa7qercy6FnIqKR7RPGCNLkEnlRst5a3Qbx9dOLQH0hDe7COKhh9abKaTRyPo87NVFkTJ+Laj5DMGwLowzupmgI8Y0nbwSgvraU50fzbi+TXoPBGgJmCH9j2UOnseIzw+3EG1ZbIm25gQtvMBlWHEbqgbPLoKeljD3gO06xQ75TVrhFwiwRAN7KVi3PIM3YtYbM4XJl551qc0Qn8Q3jIeEExIHpQudseqfd/aWCEmKE7PoyN2AJMqDPst6HzmVOjPA== 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=GckGHbbxjW1kKE3dIm2n//LiMkHkkzSA4Ki2P0ndXlQ=; b=Cl+boOAyaGq+0ZBFNq69xIiDqSHwH4IAzeSAbDZd9Q5DDFrWyVCQKiCywAjSY9347OqQKeKRM6U2FgO5RO1WuCc/S1Rq7mgWxFNCUtIFlym2r2Q6lIlvSBMFPVIItfT+amnptypbu8Pre40JG4FLvD5534ZHs4m6YuyrqR7SX4K8tfGbf/PieAR2I+3Qb8KmYGITGfgnIBbVkdp5T5YqpSTBf1vijrWSmL4C81BLiIGZX5no+5SBdCJXZS9r03OBNLv3HfGso5pa6LBW7cE4iG18MDu280oCKJ8jaVbHRuP43As3nIPATzv7cMdp6rc4eBlaUlaglmwU/ltq2o4QPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GckGHbbxjW1kKE3dIm2n//LiMkHkkzSA4Ki2P0ndXlQ=; b=cCM+F6ukBiePDb7/H7NsPVF2ThKdfRsZuFpnhPEoAu5fkyapGIQEwgcKhD4nD9uv7nevoBTwQgV/jWKLbcfnyl9U9i/SGbMt/+xQvS4Wr7AwDhfol0Lr/aOXPbsThnZ6p3OmiBu1rVkyIorcWtyzeoFkr0Apy9X6OZzseA3ODS0CrIsMgdIW4RHmFZf8V41E0lyrY0EnjRboBzZml3z1PEqxQsiOgzOyLiHLljwpmXHbhc/emwn8rxHLBp14ISgP0THMLSvABVG0oapGxGGUyDkKVh2skj5lrV5XnIEi1Cp++qmPMMKRsK/zf4gLlVoD7+Q2NnsiAV7xRzmRqnKJDw== Received: from DM6NAM10FT058.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::4d) by DM6NAM10HT059.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Tue, 2 Feb 2021 03:04:19 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e86::45) by DM6NAM10FT058.mail.protection.outlook.com (2a01:111:e400:7e86::304) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Tue, 2 Feb 2021 03:04:19 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d%4]) with mapi id 15.20.3805.028; Tue, 2 Feb 2021 03:04:19 +0000 To: Aaron Piotrowski , php internals Thread-Topic: [PHP-DEV] [RFC] Fibers Thread-Index: AQHW1JH3Qg2ZcNIGwEee0GXThHxj4KpEclKt Date: Tue, 2 Feb 2021 03:04:19 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:0A18A64DB97AF2D5E13FABA1C3D55DC67AEA2048DBF601C35508F22770EF9C03;UpperCasedChecksum:78E7DD902D9CD05EFE5A98C53831F9CE947F9FD20F1BBA54B93ED9DC9500E53C;SizeAsReceived:6960;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [aMTuRCUXOlx47j6V5vCf1c9vjESDxmSoYFTECnIDGB0i2LV2t5xntwwRHvNaQghH] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: c8da35a6-3631-4209-0acf-08d8c7273c15 x-ms-traffictypediagnostic: DM6NAM10HT059: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: t5rOkM19Tbv81QsyfNRAWjCH5caeo7DdxyGnJMYRkzcCrLKGm20yUsj9frgf2b0yFj7v87oAm2w0jP1a7lXiR0ZzPZ74TAohLE3HgAP4T0d1+6NDyICv1tACtTO6s0cd2dmz2zODYaVbDivf6lWEtE7MF5cMuX4rAgGWUJN86TsW0xUcRdT3YLv2dTO/oUFuSliDNrQCmTjvVysI/OvCHAPoKsNWbYFIzdsb67SqSi0KPZiqTgZ/zD5ZsisNa1gTS3jOKHbcviRKBFfvX1H8iJOIB839mVmWw7FqjzbYCgfJUzOGbTfgX25W3EDjBoLouI2KgSZtOk5LI6RFkDC0SkNgS3yPTYDNxpvHo0gGiSOpIOYxuopgqU7gfWbnPiplR4WloXl1NRN8Jgho3+lGbVRO4MIa8HQnIgSDQQ6h9rVT8zKQXREwAtG9lHUaoA9L x-ms-exchange-antispam-messagedata: RKLkPmSyhrZD6X3Z4W7pVZ1E0cjptC9DvFpsyRe7tGUudrZ9o+2SjFBRJmRsTo+wNjuspj/SQYug/tiGhjEPFlGzqas9ygPZVVpJM9D1wy69pf710nYxd8F5Wx5gDlBC5D8usfbS4XPbE/ScbOvvZLbCczR0819qVCdiXzr0xYmJAMz3/d0oLLX0Uer4h64JJUI3ud/PUVtLNTYAFa9NNQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: DM6NAM10FT058.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: c8da35a6-3631-4209-0acf-08d8c7273c15 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2021 03:04:19.8179 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM10HT059 Subject: Re: [PHP-DEV] [RFC] Fibers From: tysonandre775@hotmail.com (tyson andre) Hi Aaron Piotrowski,=0A= =0A= > I would like to introduce an RFC for adding full-stack fibers to PHP: htt= ps://wiki.php.net/rfc/fibers=0A= >=0A= > Fibers are primarily used to implement green-threads or coroutines for as= ynchronous I/O. Fibers are similar to threads, except fibers exist within a= single thread and require cooperative scheduling of the fibers by the proc= ess. Since fibers do not require a full CPU context switch, they are lightw= eight and more performant than multi-processing or threading for awaiting I= /O.=0A= >=0A= > An implementation as an extension is at https://github.com/amphp/ext-fibe= r=0A= >=0A= > Fibers are a complex feature. The RFC contains many examples and links to= code using fibers to help explain and demonstrate what is possible, howeve= r I=92m certain many more questions and concerns will arise. Looking forwar= d to feedback and discussion.=0A= =0A= I took a look at the amphp/ext-fiber repo a few weeks ago - nothing stood o= ut as a major concern but I'm only moderately familiar with threading,=0A= A minor comment is that it'd be easier to read the phpt test cases if the `= --EXPECTF--`=0A= section included the file's basename in the test output of error traces ins= tead of just `%s`, etc.=0A= (e.g. tests/002-throw.phpt)=0A= =0A= ```=0A= Stack trace:=0A= #0 %s(%d): {closure}()=0A= #1 %s(%d): Loop->tick()=0A= #2 %s(%d): Loop->run()=0A= ...=0A= ```=0A= =0A= I didn't see in the test cases/rfc:=0A= How do the `zend_try`/`zend_catch`/`zend_end_try` macros and `zend_error_no= return` macros get handled after a fatal error?=0A= I'm not 100% sure - I think those use setjmp/longjmp internally - will fata= l errors continue to work if there's a fatal error from within a fiber.=0A= (e.g. `require_once` on a file with a compile-time fatal error such as dupl= icate parameters).=0A= I forget exactly how they work, e.g. in the context of a web server before = this RFC - at a glance I'd guess an unrecoverable fatal error would cause t= he worker to shut down.=0A= Would being in a different fiber and different C stack interfere with the s= hutdown process for fatal errors? (I guess the macros could be changed to m= ake that switch to the main fiber if needed to fix that)=0A= =0A= Thanks,=0A= -Tyson Andre=0A=