You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Proposal] opcache.no_cache: Opcode optimization without caching
Currently, it isn't possible to enable optimizations without enabling caching.
They should be orthogonal features - it's already possible to cache without
optimization passes (`opcache.optimization_level=0`)
Being forced to either enable caching or file_cache_only causes these problems:
- For file_cache_only, users would be forced to manage the file cache,
and users may not be confident in properly handling all potential edge cases.
(Running out of disk space, need to clear stale entries, concerns about opcode
corruption not being fixed after restarting a process, etc)
- The shared memory block uses up a lot of RAM when individual PHP processes
are known to be long-lived and don't have a common memory address space.
(e.g. multiple long-lived php scripts managed by something that is not
a php script (e.g. `supervisord`, daemons, tools run in the background in
IDEs, etc))
The opcodes are duplicated in shmem, which wastes memory in use cases
where they're stored in the cache but never retrieved.
The default for opcache.memory_consumption is 128M.
Even when this isn't used, the virtual memory to track the shared
memory(shmem) segment seems to add 2MB extra per **independent** php process in
"shared memory" segments, reducing the free RAM available for other processes.
(starting a large number of php CLI scripts that sleep() in a loop,
`free` (linux program to report free memory) reports that `shared`
increases by 2MB per process without opcache.no_cache, but barely increases
with opcache.no_cache=1
On an unrelated PR php#5097 (comment)
dstogov mentioned that
> Also, it would be great to move optimizer and JIT into core, to make them
> available even without opcode caching.
This PR is one potential approach for making the optimizer and JIT available
without opcode caching.
This is currently a proof of concept - feel free to point out combinations of
settings that should be rejected.
Potential areas for future work:
- Normally, opcache optimizes a file based only on that one file's contents.
When `opcache.no_cache=1` is used, it may be possible to use all of the
class, function, constant, etc. definitions parsed from previously parsed
files (to eliminate dead code, inline function calls, etc).
0 commit comments