Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103505 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13118 invoked from network); 26 Nov 2018 14:51:37 -0000 Received: from unknown (HELO mail-io1-f54.google.com) (209.85.166.54) by pb1.pair.com with SMTP; 26 Nov 2018 14:51:37 -0000 Received: by mail-io1-f54.google.com with SMTP id l14so13440871ioj.5 for ; Mon, 26 Nov 2018 03:14:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tVbDjKmwk6J9IzW8G17U9NdeCpjO+tOOLKyLVSew8Dg=; b=nw6lu65QWeRzTakFBx7zYvCE6XGQDVvHO48u/tI0uTrBuHXsNsEjqmDSsvxcVYGuR0 U2kLIUxYU6S5nk0fTz/kgj386wCeCYz/S5n7+XI3sHpUxHDXeJhE9QgSTjr7KfTKl+Wi SvzQ91IHdCR4WjB/8l/FtXvuBk38GvNh/VwbiRvMS3fi1OyDpWJ5mjC2fgr4SVXHKVrA nSP8xjO+vqaSKiKxEkbcUpo5sGAZ6PD6G6wAhFwjXu0/e2rzveSjuKHVzEbZoDyfODMd tWflv/I4H4bBG1lkthN7oyH7iW96D4mCdvN1GJT0vkfmnSZ2MiY94GS1SRT8Tt6Qm2ik ZUSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tVbDjKmwk6J9IzW8G17U9NdeCpjO+tOOLKyLVSew8Dg=; b=B/+CGIW26gAC7ShI2D9LwT0KhdWmKbI6qKgIZqUIX/wbw+g5I/aixMdSBm2MewfFOy MXS7di00+ONjmSxYf0kvjVD5uspY8osVd9L2+/Z4IubaqoR6RLmIUSIhI20JemkUkNXy n5W9waShc/8+eCwk083yCO++bG30lUicrH3/JHIz257cIQJ2jPQ0s00yA7EECahOJ+zG yOYrW9BxxxdDlTxQPk3hGB/qwz2gvW/QUnAjL+HxrHdeKGsyo1cu7Tznl8xZsGqVjtxj Zw8AcUr6BSS1i+mFHCCA3JaDSJCLjAtLrrExgbwGj6bwJ4Oin4P2wvRyTH+zFok6Htre G2ug== X-Gm-Message-State: AA+aEWa66uzTTMZxFwwTgHjT8m45+AXSN2cY/DZu6LSjAfyujdthnZTj n2yWxDD914SFIMC9WrElH/tEoycbsdi5OxXAOWw= X-Google-Smtp-Source: AFSGD/V/C1BJTCjckeOE917gR2DzuqWVU9E7ch+TShB7u1kVZgGetYjmSB+OOKko6KGtiz0rLFKajiuxveySHqs/Oqk= X-Received: by 2002:a5e:8d13:: with SMTP id m19mr20387405ioj.258.1543230898871; Mon, 26 Nov 2018 03:14:58 -0800 (PST) MIME-Version: 1.0 References: <1cb7fecd-22ba-0ded-5bd6-e70208053012@gmail.com> <7f65012b-e26a-fb58-718b-b35569e53d03@gmail.com> In-Reply-To: Date: Mon, 26 Nov 2018 12:14:40 +0100 Message-ID: To: Zeev Suraski Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000088a164057b8f7143" Subject: Re: [PHP-DEV] declare(cache=0) - explanation (was: Re: [PHP-DEV] [mini-RFC] Disable opcache per script using "declare(cache=0)") From: nikita.ppv@gmail.com (Nikita Popov) --00000000000088a164057b8f7143 Content-Type: text/plain; charset="UTF-8" On Mon, Nov 26, 2018 at 10:15 AM Zeev Suraski wrote: > On Sun, Nov 25, 2018 at 11:43 PM Marco Pivetta wrote: > > > Is that space rrrrrrreeeeeally a problem? > > > > Take the example ZF loader from the RFC: that barely makes any difference > > at all. > > > > A stronger reasoning for another language construct (that changes engine > > behaviour) is kinfa required. > > > > The emails I've written on this thread already suggested that I tend to > agree. I just spoke with Dmitry to better understand why he cared about so > little space, and turns out he didn't either - the rationale is different > and is pretty straightforward. > > The goal of declare(cache=0) would be to avoid persisting utility > functions/classes that have to do with a particular preload.php > implementation - so that they don't become a part of the app's memory > context and 'pollute' its scope. > > For example, you may implement a preload_file() function in preload.php, or > perhaps even a class Preload{} with some utility functions that will be > responsible for include()ing all the various files you want to preload into > your server. Currently, function preload_file() / class Preload would > become permanent parts of the app's scope - and pollute it to some degree. > They're sort of meta-code that has no business sticking around in the app's > memory space once the preloading stage is over. With declare(cache=0) - > these will execute just as before, but won't be persisted into the > permanent scope (or into the OPcache at all, for that matter). > > There's no way to 'automatically' apply this 'do-not-cache', as in > different implementations - the preload.php file might actually include > classes/functions folks would actually want to persist, and in other cases > files include()ed by preload.php may in fact include functions/classes > people do not want to persist. This has to be a manually-applied feature. > > As I mentioned in another reply on this thread, it's also a nice > runtime/configurationless alternative for the blacklist feature, in case > you want to prevent certain files from being cached for whatever reason > (that use case is unrelated to the preload capability). > > I'm personally fine with this being admitted w/o a full fledged RFC if > there are no objections. > > Zeev > It would make more sense to me to not cache anything from the preload script or anything it includes, and only make things for which opcache_compile_file() is called part of the preload. As I understand it, right now both included and compiled files will be preloaded. I think that would be a better solution than a declare annotation, because it would allow you to use arbitrary code in your preload script. You could make use of normal library code -- something that would be much harder if you had to hot-patch the library to include no-cache directives first. Nikita --00000000000088a164057b8f7143--