Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PHP 7 new engine

1,244 views

Published on

PHP 7 new engine

Published in: Internet
  • Be the first to comment

PHP 7 new engine

  1. 1. PHP 7 new engine
  2. 2. PHP 7 new internals  Full 64bit support  New Thread Safety mechanism  New engine memory management  New optimized executor  New optimized structures
  3. 3. PHP 7 full 64bit engine  PHP was known to be platform dependent on this crucial criteria  LP64: Linux64 (and most Unixes)  LLP64: Windows64  ILP64: SPARC64 http://www.unix.org/whitepapers/64bit.html string size signed integer Platform int long LP64 32 64 LLP64 32 32 ILP64 64 64
  4. 4. PHP 7 full 64bit engine  PHP 7 now uses platform independant sizes  Strings > 2^31  Real 64bit userland PHP integers  LFS (Large File Support)  64bits hash keys  Whatever your platform (OS) : consistency
  5. 5. PHP 7 new memory management  PHP 7 has reworked every memory management routine  Use less heap and more stack  Zvals are stack allocated  refcount management more accurate  Scalar types are no longer refcounted  Redevelop a new MM heap, more optimized  Based on sized pools (small, medium and large)  CPU cache friendly  Concepts borrowed from tcmalloc
  6. 6. PHP 7 thread safety  PHP7 has reworked its thread safety mechanism routine  PHP 5 thread safety routine had a ~20% perf impact  This is no more the case in PHP 7  Still some more work to do, but lighter  TLS is now mature, and it is used  For PHP under Windows (mandatory)  For PHP under Unix, if asked for (usually not)
  7. 7. PHP 7 new structures  Critical structures have been reworked  More memory friendly  More CPU friendly (data alignment, cache friendly)  Strings are now refcounted  Objects now share their refcount with other types  Wasn't the case in PHP5  The engine Executor uses a full new stack frame to push and manage arguments  Function calls have been heavilly reworked
  8. 8. PHP 7 performances
  9. 9. PHP 7 performances  A lot of tweaks have been performed against PHP 7 code performances.  A lot of internal changes - invisible to userland - have been performed to have a more performant language  CPU cache misses have been heavilly worked on  Spacial locality of code is improved  This results in a language beeing at least twice fast and that consumes at least twice less memory
  10. 10. PHP 7 performances ... ... $x = TEST 0.643 0.247 $x = $_GET 0.848 0.452 $x = $GLOBALS['v'] 1.182 0.787 $x = $hash['v'] 1.025 0.629 $x = $str[0] 1.671 1.275 $x = $a ?: null 0.831 0.435 $x = $f ?: tmp 1.349 0.953 $x = $f ? $f : $a 0.919 0.523 $x = $f ? $f : tmp 1.361 0.965 ------------------------ Total 34.773 ... ... $x = TEST 0.440 0.257 $x = $_GET 0.603 0.421 $x = $GLOBALS['v'] 0.930 0.748 $x = $hash['v'] 0.669 0.486 $x = $str[0] 1.116 0.934 $x = $a ?: null 0.527 0.344 $x = $f ?: tmp 0.611 0.429 $x = $f ? $f : $a 0.550 0.367 $x = $f ? $f : tmp 0.569 0.386 ------------------------ Total 20.440 PHP7PHP5.6 Zend/micro_bench.php
  11. 11. PHP 7 performances Time: 17.62 seconds, Memory: 297.50Mb Time: 7.21 seconds, Memory: 104.00Mb PHP7 PHP5.6 PHPUnit in Symfony2 components Time gain ~ 60% Memory gain ~ 60%
  12. 12. PHP 7 CPU friendly PHP 7.0.4 (debug) 306,006739 task-clock 1 446 context-switches 4 330 page-faults 787 684 146 cycles 817 673 456 instructions 121 452 445 branches 3 356 650 branch-misses 5 741 559 cache-references 873 581 cache-misses 0,334226815 seconds time elapsed PHP 5.6.20 (debug) 456,483483 task-clock 1 405 context-switches 8 633 page-faults 1 163 771 607 cycles 1 247 617 395 instructions 181 700 375 branches 5 257 940 branch-misses 9 085 235 cache-references 1 108 044 cache-misses 0,468451813 seconds time elapsed
  13. 13. PHP 7 performances  Take care of synthetic benchmarks  They only demonstrates basic use cases  Run your own benchmarks  Run your own applications against PHP 7  On a big average, you can expect dividing CPU time and memory consumption by a factor of 2 compared to PHP-5.6, probably even more than 2
  14. 14. PHP 7 is released :-) get it now <3
  15. 15. Thank you for listening !

×