Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80218 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11775 invoked from network); 6 Jan 2015 04:21:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jan 2015 04:21:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=francois@tekwire.net; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=francois@tekwire.net; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain tekwire.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@tekwire.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:63936] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/A0-21693-BC26BA45 for ; Mon, 05 Jan 2015 23:21:32 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id C846B4B0188 for ; Tue, 6 Jan 2015 05:19:37 +0100 (CET) Reply-To: To: "'PHP Internals'" References: In-Reply-To: Date: Tue, 6 Jan 2015 05:21:26 +0100 Message-ID: <006501d02968$3cd39060$b67ab120$@tekwire.net> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQKBrOMj1TuM8+kkOgWpn3PeY833kwGP3Hvhm0LOT6A= Content-Language: fr X-Antivirus: avast! (VPS 150105-1, 05/01/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] [RFC] Extension Prepend Files From: francois@tekwire.net (=?UTF-8?Q?Fran=C3=A7ois_Laupretre?=) > -----Message d'origine----- > De : php@golemon.com [mailto:php@golemon.com] De la part de Sara = Golemon > > So, I've been meaning to propose something *like* this, but with a few > key implementation detail differences: >=20 > 1) Create the notion of "Persistent User = Functions/Classes/Constants/etc >=20 > 2) Embedded text sections First, persistent PHP code or data (NOT reloading code for each request) = is a huge can of worms. If Sara decides to re-launch the idea, that will = be great but the subject is probably out of scope here. IMHO, what we need here is a generic mechanism to embed PHP code in C = extensions and, then, execute it. It should define a way to embed PHP = scripts as C strings at compile time, how to make these scripts known = and accessible from the PHP core, and how to execute them when needed. Instead of including the runtime code in every extensions, as it is done = in ext-embed, I would prefer an extension which would provide this = service to other 'client' extensions. It would define a stream wrapper = to access the registered PHP scripts. Script registration would be = registered in persistent memory during MINIT. The registration would = return an ID for each registered script. These IDs would be stored by = the client extension and would be used to derive a stream-wrapped path = when the client decides to execute a registered script. These paths = would uniquely reference the scripts, which would allow to opcode-cache = them. As a specific case, if an extension wants to execute some PHP code at = the beginning of each request, it can execute its script(s) during = RINIT, but it is just a use case of a more general mechanism. RINIT = execution order can be resolved using module dependencies. Extending the mechanism to userspace 'plain file' scripts could be = provided by a 'bridge'. The user could register a plain file script, = whose content would be stored in persistent memory, with a flag that = would cause the script to be loaded during every RINIT. One more word about executing scripts during every RINIT : even with = opcode caches, as Sara notes, the performance hit is not negligible. The = question is always the same : What is the percentage of requests that = will really use the classes/functions we define there ? Remember that = the list of scripts is hardcoded in an extension. If the extension wants = to allow conditional loading for different features, it needs to define = appropriate ini settings. Choosing the list of scripts at compile time = is another option but would make the distribution of precompiled = binaries complex. I personally favor another approach. I still use the PHK extension as an = example of this 'intermediate' approach. This extension defines C-levels = front-end classes. These classes contain the 'fast' code. When this code = needs to access 'slow' PHP code, it executes the PHP scripts it needs, = then calls the just-defined PHP classes. This way, we preserve the = possibility to code a big part of the extension in PHP, without the = overhead of loading the PHP code at the beginning of each request. Thanks for your attention :) Fran=C3=A7ois