rfc:url-opcode-cache
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:url-opcode-cache [2017/06/02 14:26] – francois | rfc:url-opcode-cache [2017/06/19 17:20] – Added vote francois | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Add support for stream-wrapped URLs in opcode cache ====== | ====== PHP RFC: Add support for stream-wrapped URLs in opcode cache ====== | ||
- | * Version: 1.1 | + | * Version: 1.2 |
- | * Date: 2017-06-025-25 | + | * Date: 2017-06-05 |
* Author: François Laupretre, francois@tekwire.net | * Author: François Laupretre, francois@tekwire.net | ||
* Status: Under discussion | * Status: Under discussion | ||
Line 11: | Line 11: | ||
It is an extension of the ' | It is an extension of the ' | ||
- | |||
- | ===== Proposal ===== | ||
When stream wrappers were introduced in PHP, their relationship with opcode | When stream wrappers were introduced in PHP, their relationship with opcode | ||
caches was not a problem, as they were mostly used to access remote data. The | caches was not a problem, as they were mostly used to access remote data. The | ||
need for a better interaction arose with package systems, like phar and phk, as | need for a better interaction arose with package systems, like phar and phk, as | ||
- | these stream wrappers | + | these sytems use stream wrappers |
- | the scripts | + | |
- | Historically, | + | Historically, |
- | URL is considered as opcode-cacheable | + | - every URL may be considered as opcode-cacheable, |
- | a list of 'cacheable' protocols is declared explicitely in the code. opcache | + | - In order to avoid this, opcache |
- | declared | + | |
- | I consider that we need a more generic system, which must allow any PHP code handled via a stream wrapper (' | + | So, I consider that we need a more generic system, which must allow any PHP code handled via a stream wrapper (' |
+ | |||
+ | ===== Proposal ===== | ||
My previous RFC proposed the implementation of an ' | My previous RFC proposed the implementation of an ' | ||
- | * An operation named ' | + | * An operation named ' |
* A new C function named php_stream_cache_key(zend_string *path, int options, php_stream_context *context) is defined. It determines the right wrapper from the path it receives and forwards the request to the corresponding stream_cache_key() function, if it exists. If the stream_cache_key() element is not defined, NULL is returned. | * A new C function named php_stream_cache_key(zend_string *path, int options, php_stream_context *context) is defined. It determines the right wrapper from the path it receives and forwards the request to the corresponding stream_cache_key() function, if it exists. If the stream_cache_key() element is not defined, NULL is returned. | ||
- | * Userspace stream wrappers can define a method named cache_key(path [, | + | * Userspace stream wrappers can define a method named cache_key(path [, |
* For completeness, | * For completeness, | ||
Line 51: | Line 49: | ||
/* }}} */ | /* }}} */ | ||
- | In order to ensure key unicity, the returned string must start with a '<wrapper-scheme>: | + | In order to ensure key unicity, the returned string must start with the same '< |
- | The stream wrapper has the responsibility to ensure that the data associated with a given key will always be the same. | + | The stream wrapper has the responsibility to ensure that the data associated with a given key will always be the same. If this is not the case (e.g. if a ' |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 70: | Line 68: | ||
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
- | Phar needs to implement | + | Phar implements |
The same for the plain files wrapper. | The same for the plain files wrapper. | ||
- | Both changes are included in the PR below. | + | No other core extension needs to be modified. |
+ | |||
+ | When 3rd-party extensions decide to have the benefit of the new feature, they will just implement an additional ' | ||
+ | |||
+ | Userspace stream wrappers may just define a new ' | ||
==== To Opcache ==== | ==== To Opcache ==== | ||
Line 84: | Line 86: | ||
* If the returned value is non null, use this value as key to search or register the data. | * If the returned value is non null, use this value as key to search or register the data. | ||
- | These changes are NOT included in the PR below because opcache code is a performance-critical part of the core. As the change is not trivial and requires some re-organizations in the way functions call themselves, I would prefer someone more familiar with this code to implement these changes. | + | These changes are NOT included |
==== New Constants ==== | ==== New Constants ==== | ||
Line 91: | Line 93: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | |||
- | * Security check on the key returned by userspace wrappers is not implemented yet. I'll add it ASAP. | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
Line 101: | Line 101: | ||
Required majority: 50%+1 | Required majority: 50%+1 | ||
+ | |||
+ | Vote will close Monday, July 3, 2017 00:00 UTC. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== |
rfc/url-opcode-cache.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1