# [RFC] opcache.no_cache: Opcache optimization without any caching

- Thread: https://externals.io/message/110187
- Original archive: https://news-web.php.net/php.internals/110187
- Started by tyson andre on 2020-05-16T16:37:12+00:00
- Messages: 6
- RFC: Opcache optimization without any caching (Declined) — https://externals.io/rfc/opcache.no_cache.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #110187 — tyson andre — 2020-05-16T16:37:12+00:00

URL: https://externals.io/message/110187#110187

Hi internals,

I've created the RFC https://wiki.php.net/rfc/opcache.no_cache to make the opcode optimizer and JIT available without opcode caching, through a new setting `opcache.no_cache=1`.

So far, the feedback I've gotten is that having the ability to optimize without caching would be useful,
but that moving the optimizer into Zend is possibly a better solution.
(https://github.com/php/php-src/pull/5504 , 
announced two weeks ago in https://externals.io/message/109959 
"opcache.no_cache prototype: Opcode optimization without caching")

To summarize my reasons for creating the RFC without moving the optimizer:

- Even with the optimizer moved into PHP's core,
  I still think there'd be the same use case for a system ini configuration setting to disable caching.
  (in designs I can imagine)
- I consider this useful functionality to have, so I'd rather have a good solution than an ideal solution
  that currently isn't being worked on (to my knowledge)
- I'd prefer creating an RFC with small changes here.
- The discussions would be useful for future RFCs in this area.

If a viable RFC&implementation to move opcache into core is created
(and would conflict with this), I'll postpone this RFC.

Thanks,
- Tyson

---

## #110189 — Derick Rethans — 2020-05-16T18:05:42+00:00

URL: https://externals.io/message/110187#110189 · In reply to: #110187

> I've created the RFC https://wiki.php.net/rfc/opcache.no_cache to make 
> the opcode optimizer and JIT available without opcode caching, through 
> a new setting `opcache.no_cache=1`.

In my opinion, configuration names should never be "in the negative". 
Instead of defaulting to opcache.no_cache=0, default to opcache.cache=1.

cheers,
Derick

-- 
PHP 7.4 Release Manager
Host of PHP Internals News: https://phpinternals.news
Like Xdebug? Consider supporting me: https://xdebug.org/support
https://derickrethans.nl | https://xdebug.org | https://dram.io
twitter: @derickr and @xdebug

---

## #110191 — tyson andre — 2020-05-16T18:45:01+00:00

URL: https://externals.io/message/110187#110191 · In reply to: #110189

> In my opinion, configuration names should never be "in the negative". 
>  Instead of defaulting to opcache.no_cache=0, default to opcache.cache=1.

I see your point - there are only a few negative ini names I see in `phpinfo()` (disable_functions, disable_cache), and those are for lists of strings.

There's a mix of on by default and off by default in
zend.enable_gc, opcache.enable, opcache.enable_cli, opcache.enable_file_override,
enable_dl, and enable_post_data_reading.

opcache.enable_cache=1 as the default would probably be more consistent with those.
But the setting isn't actually enabling cache, it's allowing cache (i.e. opposite of disabling),
so making this "opcache.allow_cache" might be the best. I'll probably go with that.
(similar to allow_url_fopen, allow_url_include)

- `opcache.cache` could be confused with the caching strategy or the path to the cache,
  or being sufficient on its own to enable caching

Thanks,
- Tyson

---

## #110232 — tyson andre — 2020-05-21T14:07:28+00:00

URL: https://externals.io/message/110187#110232 · In reply to: #110191

Hi internals,

https://wiki.php.net/rfc/opcache.no_cache has been updated.
Instead of opcache.no_cache=1, opcache.enable_cache=0 is now used to disable caching.

In the RFC, I wrote that `opcache_get_status()` now includes the following new booleans

- `optimizations_enabled`, which is true if any optimization passes will get run.
- `allow_cache`, which will be true if any form of opcode caching is enabled.
  Maybe `cache_opcodes` or `opcode_cache_enabled` would be a better name.

Any thoughts on whether `opcache_get_status()` should be changed at all here?
It's probably possible but inconvenient to determine what's being done with `extension_loaded()` and multiple calls to `ini_get()`,
and the intended meaning of existing flags such as `opcache_enabled` was never documented
in https://www.php.net/opcache_get_status

Any other thoughts on the RFC?

> > […]
> > Instead of defaulting to opcache.no_cache=0, default to opcache.cache=1.
> 
> ... the setting isn't actually enabling cache, it's allowing cache (i.e. opposite of disabling),
> so making this "opcache.allow_cache" might be the best. I'll probably go with that.
> (similar to allow_url_fopen, allow_url_include)
> 
> ... `opcache.cache` could be confused with the caching strategy or the path to the cache,
> or being sufficient on its own to enable caching

Thanks,
- Tyson

---

## #110233 — Albert Casademont — 2020-05-21T14:46:51+00:00

URL: https://externals.io/message/110187#110233 · In reply to: #110232

Hi tyson,

Thanks for your RFC. As ReactPHP users this is a very welcome change. Right
now we have to enable file_cache only for the optimizations, as there's no
real benefit of the full opcache in long-running CLI apps. Having this
setting would allow us to even stop using file_cache but get the opcache
optimizations. It would be even better if these optimizations moved into
PHP Core.

Thank you!

Albert

On Thu, May 21, 2020 at 4:07 PM tyson andre <tysonandre775@hotmail.com>
wrote:

> Hi internals,
>
> https://wiki.php.net/rfc/opcache.no_cache has been updated.
> Instead of opcache.no_cache=1, opcache.enable_cache=0 is now used to
> disable caching.
>
> In the RFC, I wrote that `opcache_get_status()` now includes the following
> new booleans
>
> - `optimizations_enabled`, which is true if any optimization passes will
> get run.
> - `allow_cache`, which will be true if any form of opcode caching is
> enabled.
>   Maybe `cache_opcodes` or `opcode_cache_enabled` would be a better name.
>
> Any thoughts on whether `opcache_get_status()` should be changed at all here?
> It's probably possible but inconvenient to determine what's being done
> with `extension_loaded()` and multiple calls to `ini_get()`,
> and the intended meaning of existing flags such as `opcache_enabled` was
> never documented
> in https://www.php.net/opcache_get_status
>
> Any other thoughts on the RFC?
>
> > […]
> opcache.cache=1.
> > […]
> opposite of disabling),
> > […]
> with that.
> > […]
> path to the cache,
> > […]
>
> Thanks,
> - Tyson

---

## #110294 — tyson andre — 2020-05-28T17:14:59+00:00

URL: https://externals.io/message/110187#110294 · In reply to: #110232

Hi internals,

If there are no unexpected issues,
then voting will start on https://wiki.php.net/rfc/opcache.no_cache in 2 days, on May 30th.

Thanks,
- Tyson
