SlideShare a Scribd company logo
1 of 26
Download to read offline
MANOMANO
Preloading: a Post-Scriptum
Checking on an old friend
ManoMano confidential
The timeline
2018 2019 2020 😷 2021 2022
PHP RFC:
Preloading
Author: Dmitry Stogov
PHP 7.4 release Nothing to
report
Please disperse
Inheritance
cache released
in php 8.1
Author: see first block
Slides for talk
created
Author: yours truly
ManoMano confidential
Preloading of what?
(opcache) preloading
<?php
echo "hello world";
line #* E I O op fetch ext return operands
-------------------------------------------------------------------------------------
3 0 E > ECHO 'hello+world'
1 > RETURN 1
010001010100101001
101010100101000001
010110001001000111
ManoMano confidential
Why do we even need opcodes / bytecodes?
ManoMano confidential
How can I see the opcodes? 🔍
● Use 3v4l: https://3v4l.org/UIjRD/vld
● php -d opcache.enable_cli=1 -d
opcache.opt_debug_level=0x10000 hello_world.php
● phpdbg -p* hello_world.php
● php -d vld.active=1 hello_world.php
https://www.npopov.com/2017/04/14/PHP-7-Virtual-machine.html
ManoMano confidential
What happens when executing a PHP program?
Let’s accelerate! 🏎
ManoMano confidential
List of PHP Accelerators
● APC: bytecode cache (💀 since PHP 5.5) and user cache (split to
✨APCu✨)
● eAccelerator: 💀 since PHP 5.5, forked from Turck MMCache, 💀
since PHP 5.2
● ionCube: still alive, closed source, must pay 💰, main feature is
encryption
● XCache: 💀 since PHP 5.6
● Nusphere phpexpress: 💀 since PHP 5.4
● 👉 Zend OPCache: ✨alive and kicking✨
● Zend Platform: 💀 since PHP 5.2
● Windows Cache: 👽 works I suppose, but who cares?
ManoMano confidential
With opcache
but without preloading
ManoMano confidential
With opcache
but without preloading
For each and every file:
ManoMano confidential
With preloading
autoloading is bypassed *
* for preloaded symbols.
Otherwise, see previous slide
Since PHP 7.4
But wait, there’s more!
ManoMano confidential
Type dependencies resolution
ManoMano confidential
Type dependencies resolution
ManoMano confidential
Without preloading, this happens at runtime
ManoMano confidential
With preloading, this happens once, when starting
php-fpm
Only classes without unresolved parent, interfaces,
traits and constant values may be preloaded.
ManoMano confidential
With preloading, this happens once, when starting
php-fpm
PHP Warning: Can't preload unlinked class B: Class B cannot extend final class A in
/tmp/B.php on line 9
💥
To play with preloading in the CLI:
● opcache.preload=/tmp/preload.php
● opcache.enable_cli=On
ManoMano confidential
What should you put inside preload.php?
Symfony: let the framework decide, optionally fine tune it
ManoMano confidential
Caveats
The preload file has to exist before php-fpm starts! Make sure to do a cache
warmup!
ManoMano confidential
Caveats
Preloading is not per-pool, but php-fpm won’t complain if you try to
configure it per pool 😬
ManoMano confidential
How do I make sure it’s enabled?
● Use opcache_get_status()
● Check for preload_statistics
ManoMano confidential
Conclusion on preloading
● trade off
● needs work from
○ your SRE team
○ your framework
○ yourself of course
● hard to setup
Did I just waste your time?
ManoMano confidential
Inheritance cache
ManoMano confidential
Inheritance cache
Since PHP 8.1, without configuring anything
Send me your benchmarks 🙏
🐘 @greg0ire@phpc.social
🐦 @greg0ire

More Related Content

Similar to Preloading, a Post-Scriptum.pdf

Setting up a debugging environment for Drupal
Setting up a debugging environment for DrupalSetting up a debugging environment for Drupal
Setting up a debugging environment for Drupal
jonlee554
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
Combell NV
 
Dockerfish-Tutorial
Dockerfish-TutorialDockerfish-Tutorial
Dockerfish-Tutorial
Brian Hood
 

Similar to Preloading, a Post-Scriptum.pdf (20)

6. hands on - open mano demonstration in remote pool of servers
6. hands on - open mano demonstration in remote pool of servers6. hands on - open mano demonstration in remote pool of servers
6. hands on - open mano demonstration in remote pool of servers
 
Installing Lamp Stack on Ubuntu Instance
Installing Lamp Stack on Ubuntu InstanceInstalling Lamp Stack on Ubuntu Instance
Installing Lamp Stack on Ubuntu Instance
 
Phalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil ConferencePhalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil Conference
 
Symfony: A Brief Introduction
Symfony: A Brief IntroductionSymfony: A Brief Introduction
Symfony: A Brief Introduction
 
Getting started with robonova in ubuntu
Getting started with robonova in ubuntuGetting started with robonova in ubuntu
Getting started with robonova in ubuntu
 
Php7
Php7Php7
Php7
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
 
Setting up a debugging environment for Drupal
Setting up a debugging environment for DrupalSetting up a debugging environment for Drupal
Setting up a debugging environment for Drupal
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confoo
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
 
PHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentationPHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentation
 
Running Symfony
Running SymfonyRunning Symfony
Running Symfony
 
Last Month in PHP - June 2016
Last Month in PHP - June 2016Last Month in PHP - June 2016
Last Month in PHP - June 2016
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
Inner Symfony’s Daemons
Inner Symfony’s DaemonsInner Symfony’s Daemons
Inner Symfony’s Daemons
 
Inner Symfony’s Daemons
 Inner Symfony’s Daemons Inner Symfony’s Daemons
Inner Symfony’s Daemons
 
Dockerfish-Tutorial
Dockerfish-TutorialDockerfish-Tutorial
Dockerfish-Tutorial
 
AMIMOTO: WordPress + Amazon Web Services Hands-on PARIS
AMIMOTO: WordPress + Amazon Web Services Hands-on PARISAMIMOTO: WordPress + Amazon Web Services Hands-on PARIS
AMIMOTO: WordPress + Amazon Web Services Hands-on PARIS
 
симфони это не страшно
симфони   это не страшносимфони   это не страшно
симфони это не страшно
 

Recently uploaded

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
Health
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 

Recently uploaded (20)

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 

Preloading, a Post-Scriptum.pdf