summaryrefslogtreecommitdiff
path: root/ext/opcache/zend_shared_alloc.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2021-02-09 22:53:57 +0300
committerDmitry Stogov <dmitry@zend.com>2021-02-09 22:53:57 +0300
commit4b79dba93202ed5640dff317046ce2fdd42e1d82 (patch)
treec9d35bb7fba407405d14e1fb8c1dd1df3e0f8da7 /ext/opcache/zend_shared_alloc.c
parent550aee0be3bf256fc1dec5409ad1262c96b23147 (diff)
downloadphp-git-4b79dba93202ed5640dff317046ce2fdd42e1d82.tar.gz
Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance. PHP classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request. Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking). The patch shows 8% improvement on Symphony "Hello World" app.
Diffstat (limited to 'ext/opcache/zend_shared_alloc.c')
-rw-r--r--ext/opcache/zend_shared_alloc.c33
1 files changed, 9 insertions, 24 deletions
diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c
index 698c2884ca..a078a31c0f 100644
--- a/ext/opcache/zend_shared_alloc.c
+++ b/ext/opcache/zend_shared_alloc.c
@@ -375,7 +375,7 @@ int zend_shared_memdup_size(void *source, size_t size)
return ZEND_ALIGNED_SIZE(size);
}
-static zend_always_inline void *_zend_shared_memdup(void *source, size_t size, bool arena, bool get_xlat, bool set_xlat, bool free_source)
+static zend_always_inline void *_zend_shared_memdup(void *source, size_t size, bool get_xlat, bool set_xlat, bool free_source)
{
void *old_p, *retval;
zend_ulong key;
@@ -388,13 +388,8 @@ static zend_always_inline void *_zend_shared_memdup(void *source, size_t size, b
return old_p;
}
}
- if (arena) {
- retval = ZCG(arena_mem);
- ZCG(arena_mem) = (void*)(((char*)ZCG(arena_mem)) + ZEND_ALIGNED_SIZE(size));
- } else {
- retval = ZCG(mem);
- ZCG(mem) = (void*)(((char*)ZCG(mem)) + ZEND_ALIGNED_SIZE(size));
- }
+ retval = ZCG(mem);
+ ZCG(mem) = (void*)(((char*)ZCG(mem)) + ZEND_ALIGNED_SIZE(size));
memcpy(retval, source, size);
if (set_xlat) {
if (!get_xlat) {
@@ -411,42 +406,32 @@ static zend_always_inline void *_zend_shared_memdup(void *source, size_t size, b
void *zend_shared_memdup_get_put_free(void *source, size_t size)
{
- return _zend_shared_memdup(source, size, 0, 1, 1, 1);
+ return _zend_shared_memdup(source, size, 1, 1, 1);
}
void *zend_shared_memdup_put_free(void *source, size_t size)
{
- return _zend_shared_memdup(source, size, 0, 0, 1, 1);
+ return _zend_shared_memdup(source, size, 0, 1, 1);
}
void *zend_shared_memdup_free(void *source, size_t size)
{
- return _zend_shared_memdup(source, size, 0, 0, 0, 1);
+ return _zend_shared_memdup(source, size, 0, 0, 1);
}
void *zend_shared_memdup_get_put(void *source, size_t size)
{
- return _zend_shared_memdup(source, size, 0, 1, 1, 0);
+ return _zend_shared_memdup(source, size, 1, 1, 0);
}
void *zend_shared_memdup_put(void *source, size_t size)
{
- return _zend_shared_memdup(source, size, 0, 0, 1, 0);
+ return _zend_shared_memdup(source, size, 0, 1, 0);
}
void *zend_shared_memdup(void *source, size_t size)
{
- return _zend_shared_memdup(source, size, 0, 0, 0, 0);
-}
-
-void *zend_shared_memdup_arena_put(void *source, size_t size)
-{
- return _zend_shared_memdup(source, size, 1, 0, 1, 0);
-}
-
-void *zend_shared_memdup_arena(void *source, size_t size)
-{
- return _zend_shared_memdup(source, size, 1, 0, 0, 0);
+ return _zend_shared_memdup(source, size, 0, 0, 0);
}
void zend_shared_alloc_safe_unlock(void)