rfc:direct-execution-opcode
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:direct-execution-opcode [2020/12/10 12:33] – chopins | rfc:direct-execution-opcode [2021/04/23 18:07] (current) – Deadline has passed. RFC is declined. imsop | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2020-11-13 | * Date: 2020-11-13 | ||
* Author: chopins xiao(chopins.xiao@gmail.com) | * Author: chopins xiao(chopins.xiao@gmail.com) | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Allow php direct execution opcode file without php source file. | + | The current OPCache cannot get rid of the source file to execute the opcode file. The path will allow OPCache |
+ | |||
+ | This function is similar to java, python, .net etc. performing bytecode functions. However, the existing execution and operation mechanism of PHP is not changed. | ||
===== Proposal ===== | ===== Proposal ===== | ||
Line 21: | Line 23: | ||
</ | </ | ||
- | ==== Implementation Method==== | + | ==== Implement a schematic flowchart |
- | **compile to file:** | + | === The PHP source code file is compiled into an opcode file flowchart: === |
- | 1. current | + | 1. current |
+ | < | ||
+ | [php-load-source] ---> [compile to opcode] ---> | ||
+ | </ | ||
- | php**--->**load code**--->**compile to opcode | + | 2. path change to process: |
+ | < | ||
+ | [php-load-source] | ||
+ | </ | ||
- | 2. path added optional: | + | 3. When specified |
- | + | ||
- | php---> | + | |
- | + | ||
- | new opcode file format like below: | + | |
<PHP> | <PHP> | ||
Line 39: | Line 43: | ||
</ | </ | ||
- | **opcache exec process:** | + | **The above code explains:** |
+ | - **<? | ||
+ | - **{phpversionid}**: | ||
+ | - **OPCACHE575d367cc725713f6f170910d6e9ee5e**: | ||
+ | - **-------BINARY CONTENT OF OPCODE----**: | ||
+ | |||
+ | === OPCache extentsion exec flowchart: === | ||
- | 1. current opcache exec: | + | 1. current opcache exec process: |
<PHP> | <PHP> | ||
- | [php]--> | + | [php] ---> [find cache in cache system directory] |
- | | + | |
</ | </ | ||
- | 2. path added optional: | + | 2. path added process: |
<PHP> | <PHP> | ||
- | [php/ | + | [php/ |
- | \---->[not phpo] ---> [find cache in cache system directory]--> | + | |
- | | + | \---> [not found] |
</ | </ | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | Magic constant **%%__FILE__%%** is the absolute path to the compiled | + | PHP's constant is similar to a C macro,their values are determined when compiled into opcode. Therefore, the value of the system-related constant depends on the compiler' |
+ | So magic constant **%%__FILE__%%** is set to the absolute path of the compiler' | ||
The file path obtained by **error reporting**, | The file path obtained by **error reporting**, | ||
Line 84: | Line 95: | ||
* set 1, default value, different version opcode file exec are prohibited | * set 1, default value, different version opcode file exec are prohibited | ||
* set 0, different version opcode file will report **E_WARNING** message | * set 0, different version opcode file will report **E_WARNING** message | ||
+ | |||
+ | ===== Some scenarios ===== | ||
+ | - This RFC will avoid cold start on the WEB service and avoid opcache expiration. For example, when deploying PHP applications through docker, cold starts are avoided when adding docker services. | ||
+ | - Desktop applications developed with PHP, but require some code protection to avoid being easily modified. For example, internal systems, but can avoid non-professional error modifications. | ||
+ | - Zend Guard can be simply replaced. | ||
+ | - The php project is compiled into a binary file instead of packaged into a file. | ||
+ | - To some extent, the security of code deployed on public servers is protected, such as shared hosts | ||
+ | |||
+ | ===== Vote ===== | ||
+ | Voting opens 2021-04-05 and 2021-04-20 at 00:00:00 UTC. 2/3 required to accept. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
Line 90: | Line 116: | ||
===== Implementation ===== | ===== Implementation ===== | ||
[[https:// | [[https:// | ||
+ | |||
+ | ===== References ===== | ||
+ | - [[https:// | ||
+ | - [[https:// |
rfc/direct-execution-opcode.1607603616.txt.gz · Last modified: 2020/12/10 12:33 by chopins