rfc:preload

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:preload [2018/10/22 09:06]
nikic Fix typos etc
rfc:preload [2019/01/21 18:20] (current)
cmb Add link to manual
Line 3: Line 3:
   * Date: 2018-10-18   * Date: 2018-10-18
   * Author: Dmitry Stogov, dmitry@zend.com   * Author: Dmitry Stogov, dmitry@zend.com
-  * Status: ​Under Discussion+  * Status: ​Implemented
   * First Published at: http://​wiki.php.net/​rfc/​preload   * First Published at: http://​wiki.php.net/​rfc/​preload
  
Line 51: Line 51:
  
 As mentioned above, preloaded files remain cached in opcache memory forever. Modification of their corresponding source files won't have any effect without another server restart. All functions and most classes defined in these files will be permanently loaded into PHP's function and class tables and become permanently available in the context of any future request. During preloading, PHP also resolves class dependencies and links with parent, interfaces and traits. It also removes unnecessary includes and performs some other optimizations. As mentioned above, preloaded files remain cached in opcache memory forever. Modification of their corresponding source files won't have any effect without another server restart. All functions and most classes defined in these files will be permanently loaded into PHP's function and class tables and become permanently available in the context of any future request. During preloading, PHP also resolves class dependencies and links with parent, interfaces and traits. It also removes unnecessary includes and performs some other optimizations.
 +
 +''​opcache_reset()''​ is not going to reload preloaded files. It's just not possible using current opcache design, because during restart, they may be used by some process, and any modifications may lead to crash.
 +
 +''​opcache_get_status''​ is extended to provide information about preloaded functions, classes and scripts under the "​preload_statistics"​ index.
 +
 +==== Static members and static variables ====
 +To avoid misunderstanding,​ it is clear stated that preloading doesn'​t change the behavior of static class members and static variables. Their values are not going to relive request boundary.
  
 ==== Preloading Limitation ==== ==== Preloading Limitation ====
 Only classes without unresolved parent, interfaces, traits and constant values may be preloaded. ​ If a class doesn'​t satisfy to this condition, it's stored in opcache SHM as a part of corresponding PHP script in the same way as without preloading. Only classes without unresolved parent, interfaces, traits and constant values may be preloaded. ​ If a class doesn'​t satisfy to this condition, it's stored in opcache SHM as a part of corresponding PHP script in the same way as without preloading.
-Also, only top-level entities that are not nested within control structures (e.g. if()...) may be preloaded. ​ +Also, only top-level entities that are not nested within control structures (e.g. if()...) may be preloaded. 
 + 
 +On Windows, it's also not possible to preload classes inherited from internal ones. Windows ASLR and absence of fork() don't allow to guarantee the same addresses of internal classes in different processes.
  
 ==== Implementation Details ==== ==== Implementation Details ====
Line 71: Line 80:
 ==== php.ini Defaults ==== ==== php.ini Defaults ====
   * opcache.preload - specifies a PHP script that is going to be compiled and executed at server start-up.   * opcache.preload - specifies a PHP script that is going to be compiled and executed at server start-up.
- 
-===== Open Issues ===== 
-  * preloading in ZTS build is not supported yet 
  
 ===== Performance ===== ===== Performance =====
Line 84: Line 90:
   * In conjunction with ext/FFI (dangerous extension), we may allow FFI functionality only in preloaded PHP files, but not in regular ones   * In conjunction with ext/FFI (dangerous extension), we may allow FFI functionality only in preloaded PHP files, but not in regular ones
   * It's possible to perform more aggressive optimizations and generate better JIT code for preloaded functions and classes (similar to HHVM Repo Authoritative mode in HHVM)   * It's possible to perform more aggressive optimizations and generate better JIT code for preloaded functions and classes (similar to HHVM Repo Authoritative mode in HHVM)
 +  * It would be great, to extend preloading with some kind of deployment mechanism, to update preloaded bundle(s) without server restart. ​
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
-The RFC requires 50%+1 majority+The RFC requires 50%+1 majority. The voting started **2018-11-06** and will close on **2018-11-14** 
 + 
 +<doodle title="​Include preloading ability into PHP-7.4"​ auth="​dmitry"​ voteType="​single"​ closed="​true">​ 
 +   * Yes 
 +   * No 
 +</​doodle>​
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
Line 93: Line 105:
 ===== Implementation ===== ===== Implementation =====
 After the project is implemented,​ this section should contain ​ After the project is implemented,​ this section should contain ​
-  - the version(s) it was merged into +  - merged into 7.4 
-  - a link to the git commit(s) +  - git commit ​[[https://​github.com/​php/​php-src/​commit/​f6d227ed4f5d4c0276eb720806e808baceb37f10|f6d227ed4f5d4c0276eb720806e808baceb37f10]] 
-  - a link to the PHP manual entry for the feature +  - a [[http://​php.net/​manual/​en/​opcache.configuration.php#​ini.opcache.preload|link]] to the PHP manual entry for the feature
-  - a link to the language specification section (if any)+
  
 ===== References ===== ===== References =====
Line 105: Line 116:
   * [[https://​docs.hhvm.com/​hhvm/​advanced-usage/​repo-authoritative|Repo Authoritative mode in HHVM]]   * [[https://​docs.hhvm.com/​hhvm/​advanced-usage/​repo-authoritative|Repo Authoritative mode in HHVM]]
   * [[https://​github.com/​php/​php-src/​commit/​d57cd36e47b627dee5b825760163f8e62e23ab28|Immutable Classes implementation in PHP]]   * [[https://​github.com/​php/​php-src/​commit/​d57cd36e47b627dee5b825760163f8e62e23ab28|Immutable Classes implementation in PHP]]
- 
-===== Rejected Features ===== 
-Keep this updated with features that were discussed on the mail lists. 
rfc/preload.1540199203.txt.gz · Last modified: 2018/10/22 09:06 by nikic