Closed rask closed 4 years ago
Quick question: what is your target OS platform? If it is Windows, then preloading is broken there (and as of 7.4.2 it was disabled). And if it isn't Windows, we still need to wait for 7.4.3 to have several fixes related to preloading and opcache.
I have tested preloading prior 7.4.2 and was managed to make it working, but tricky and unstable. Let me check if it is broken now or not...
Ok, it is working under Unix, version PHP 7.4.3-dev
. My configuration is following:
[opache]
zend_extension=opcache.so
opcache.validate_timestamps=0
opcache.enable_cli=1
opcache.enable=1
opcache.preload=/path/to/z-engine/preload.php
[ffi]
ffi.enable=preload
I'm on Ubuntu and latest available PHP from deb.sury.org.
Strange. For me that does not work. PHP requires me to set opcache.preload_user
. And after I set opcache.preload_user
I get errors about FFI::load()
being disabled if opcache.preload_user
is set. It says I need to add a header file path into ffi.preload
.
Need to investigate. Are you running PHP-FPM/pools as root? I'm not using 7.4.3-dev so need to try that out also in case something's changed.
Thanks! Sorry for a tad off-topic question.
Hello again.
Solved. opcache.preload
with FFI::load()
works when running the PHP-FPM master process as non-root. deb.sury.org PPA and similar often install PHP-FPM using root as the process manager user.
Things also work normally when running the built-in web server.
Thanks again, and sorry for the noise.
https://github.com/lisachenko/z-engine/blob/45b06747a7e8163e468e3ac83b0c0859740dafd8/src/Core.php#L266
I could not get
FFI::load()
to work in preload. Have you tested this and verified that it works? What does yourphp.ini
opcache
andffi
config look like for a working preload setup?The problem in my tests is that
opcache.preload
requiresopcache.preload_user
to be set, which in turn disablesFFI::load()
if set. Which in turn means I have to manually setheader.h
in theffi.preload
INI config.The aim would be to have
FFI::load()
inside preload, andFFI::scope()
outside preload.