Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102053 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26470 invoked from network); 17 Apr 2018 16:44:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2018 16:44:40 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 104.47.32.139 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 104.47.32.139 mail-sn1nam01on0139.outbound.protection.outlook.com Received: from [104.47.32.139] ([104.47.32.139:6472] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/9C-36099-67426DA5 for ; Tue, 17 Apr 2018 12:44:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=vVBTBQV9uhSIdRbvAIOf+O7t9fhJyu5XNIimtg8i4QM=; b=Col6PTNSH6RcDDXezaJ62AyT9/k+S1K86ZQxRhVS6lU2rCDdTUlD0TlmXyliRuH04cZvKsorPILLWuFMsJrPvmEmVr81Bzv+KLDFZs6eBXYdQrO0t3JhwevRj+aDO5OJW9QTEGetCdTBV+D34QhaBwlYSu6hCYWq29jfwErUKw8= Received: from BN6PR02MB3234.namprd02.prod.outlook.com (10.161.152.32) by BN6PR02MB2514.namprd02.prod.outlook.com (10.173.141.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.696.12; Tue, 17 Apr 2018 16:44:35 +0000 Received: from BN6PR02MB3234.namprd02.prod.outlook.com ([fe80::b5e1:42c:d6ad:56c]) by BN6PR02MB3234.namprd02.prod.outlook.com ([fe80::b5e1:42c:d6ad:56c%13]) with mapi id 15.20.0675.015; Tue, 17 Apr 2018 16:44:35 +0000 To: Jakub Zelenka CC: PHP internals list Thread-Topic: FPM preloading of PHP files Thread-Index: AQHT1lerlsdxF46zs0KR37j9XO6GYqQFJc4F Date: Tue, 17 Apr 2018 16:44:35 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmitry@zend.com; x-originating-ip: [212.232.72.197] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BN6PR02MB2514;7:WGhT5ntMTpsDuYMRYX5mLty06z9/kivWgGn0uHVMl2cpX4UPKmRe8Af4sqhKB7BjG6tlivJxNoka1WDOQbUxtN25GJTNvv3hxcqtYuiMFFKtHzEZKR6mkZ7upI0Sv1MxsW1i19pVX9ca6L/pysJGpa2gQDZr0taQgiD6FcJx6yu/0o/JWg1gDj45Ph3bphOODIu+WLZFdvi2Cp1Zq6/REMX43uTfWj+o4V5V0RUeG2QieS9pvaf4jDtTrVpK1IeH x-ms-exchange-antispam-srfa-diagnostics: SOS; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:BN6PR02MB2514; x-ms-traffictypediagnostic: BN6PR02MB2514: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(192374486261705)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231232)(944501327)(52105095)(93006095)(93001095)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(6072148)(201708071742011);SRVR:BN6PR02MB2514;BCL:0;PCL:0;RULEID:;SRVR:BN6PR02MB2514; x-forefront-prvs: 0645BEB7AA x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39850400004)(376002)(39380400002)(346002)(366004)(189003)(199004)(51444003)(2900100001)(99286004)(86362001)(6436002)(19627405001)(478600001)(6916009)(8936002)(316002)(53546011)(102836004)(76176011)(2906002)(606006)(4326008)(16799955002)(6506007)(7696005)(105586002)(59450400001)(26005)(476003)(229853002)(66066001)(486006)(25786009)(68736007)(7736002)(11346002)(6116002)(446003)(3846002)(3660700001)(5660300001)(33656002)(236005)(186003)(53936002)(55016002)(74316002)(9686003)(81166006)(6606003)(3280700002)(6246003)(81156014)(54896002)(6306002)(8676002)(106356001)(966005)(5250100002)(97736004)(14454004);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR02MB2514;H:BN6PR02MB3234.namprd02.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: zend.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +SUKTvkV5Fr3HSfvXLfe3mtvX91MuCtjFDAZX+e3TrxJuy4gktSaBz3l7fP51/iJWpiqM0eXuRatLdiA5VpXQQGVwDAmteOA3Re4LaODn7qTiB8sxu/j/MMWz2yibgU4QY9eKfa07H2i4+DKBDcm0w8Jgx6uuf2xG41o/MjQpf9OlHh5clXZS7/9RUCTDBiz spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_BN6PR02MB3234013671F23A6981B13632BFB70BN6PR02MB3234namp_" MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 68f5408b-333d-4b03-3905-08d5a4828089 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68f5408b-333d-4b03-3905-08d5a4828089 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Apr 2018 16:44:35.1192 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB2514 Subject: Re: FPM preloading of PHP files From: dmitry@zend.com (Dmitry Stogov) --_000_BN6PR02MB3234013671F23A6981B13632BFB70BN6PR02MB3234namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Jakub, I though not only about FPM, but a technology for any SAPI. Pre-loaded classes and functions might be kept in CG() tables, in the same = way as "internal" ones. EG() constants and variables may be re-created at start of request, executi= ng pre-loaded PHP code. Few years ago, I developed something similar for PHP-5. Thanks. Dmitry. ________________________________ From: jakub.php@gmail.com on behalf of Jakub Zelenka = Sent: Tuesday, April 17, 2018 5:23:30 PM To: Dmitry Stogov Cc: PHP internals list Subject: FPM preloading of PHP files Hi Dmitry, This is a bit different topic to FFI discussion so creating a new thread. Y= ou wrote this in the FFI extension discussion: At the same time, we will develop a technology to preload and reuse PHP fi= les across requests. And allow FFI there. Have you been thinking about it in the FPM context? I'm asking as I have be= en pondering with a related idea about some restructuring how things work c= urrently in the FPM. I will try to give a quick overview of the current way= how things work (for those who read this and are not familiar with it), th= e problem that it is already causing and finally the idea that I have. :) The thing is that at the moment there is just a master process that except = other things does the module init and spawns children. Each child is then c= onfigured by the pool configuration which means that it can have a differen= t effective user id. It's simple and it works in most cases. However there = is an issue if it tries to access shared resources in other pools running u= nder different user which can happen due to the fact that the initializatio= n is done during MINIT by master (root user in such case). One example is = the opcache that tries to kill lockers as described in https://bugs.php.net= /bug.php?id=3D74709 . I think that it's also not ideal to do MINIT as a roo= t from security point of view (the last security issue is actually good exa= mple of that - https://bugs.php.net/bug.php?id=3D75605 ). However not sure = if there are some extension that depends on it. As you can imagine, it would get even worse if you allow preloading of PHP = script in master so such implementation would be a no-go IMHO. What I have been thinking about is to have a new process (I will call it a = pool manager) for each pool that would except other things spawn and manage= children and run under the same user. It would also do the MINIT and it co= uld possibly preload PHP files and load the libraries for FFI (considering = there would be a support in the engine for that - some kind of partial exec= ution or whatever you think would be best). Master would then spawn and man= age the pool managers as well as doing other things like log handling. That= would prevent the user mix up mentioned above - in the example case, the o= pcache would have separate shared memory for each pool. WDYT? Cheers Jakub --_000_BN6PR02MB3234013671F23A6981B13632BFB70BN6PR02MB3234namp_--