Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
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.
- Loading branch information
Showing
41 changed files
with
1,595 additions
and
1,011 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --TEST-- | ||
| static variables in methods inherited from parent class | ||
| --FILE-- | ||
| <?php | ||
| class C { | ||
| function foo ($y = null) { | ||
| static $x = null; | ||
| if (!is_null($y)) { | ||
| $x = [$y]; | ||
| } | ||
| return $x; | ||
| } | ||
| } | ||
| $c = new C(); | ||
| $c->foo(42); | ||
| $d = new class extends C {}; | ||
| var_dump($d->foo()); | ||
| var_dump($d->foo(24)); | ||
| var_dump($c->foo()); | ||
| ?> | ||
| --EXPECT-- | ||
| array(1) { | ||
| [0]=> | ||
| int(42) | ||
| } | ||
| array(1) { | ||
| [0]=> | ||
| int(24) | ||
| } | ||
| array(1) { | ||
| [0]=> | ||
| int(42) | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --TEST-- | ||
| static variables in methods inherited from parent class (can't cache objects) | ||
| --FILE-- | ||
| <?php | ||
| class C { | ||
| function foo ($y = null) { | ||
| static $x = null; | ||
| if (!is_null($y)) { | ||
| $x = [$y]; | ||
| } | ||
| return $x; | ||
| } | ||
| } | ||
| $c = new C(); | ||
| $c->foo(new stdClass); | ||
| $d = new class extends C {}; | ||
| var_dump($d->foo()); | ||
| var_dump($d->foo(24)); | ||
| var_dump($c->foo()); | ||
| ?> | ||
| --EXPECT-- | ||
| array(1) { | ||
| [0]=> | ||
| object(stdClass)#2 (0) { | ||
| } | ||
| } | ||
| array(1) { | ||
| [0]=> | ||
| int(24) | ||
| } | ||
| array(1) { | ||
| [0]=> | ||
| object(stdClass)#2 (0) { | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.