SlideShare a Scribd company logo
1 of 21
PHP Performances De Cock Xavier
Who am I? ,[object Object]
Various in house extensions ,[object Object],[object Object]
What is PHP ? ,[object Object]
Scripting engine ,[object Object]
Extensions providing functionalities
Zend Engine ,[object Object]
Source code compilation to Opcode
Opcode Handling
Memory management
Meet The Zval ,[object Object]
Benefits ,[object Object]
Automatic type conversion
Automatic garbage collection when ref_count is 0
As of PHP 5.3 Cyclic garbage collector
Zval Examples <?php $a = 41 ;  /* Context (&quot;a&quot; => Zval_1);  * Zval_1 {ref_count:1, value:41, type:LONG}; */ $b  =  $a ;  /* Context (&quot;a&quot; => Zval_1, &quot;b&quot; => Zval_1);  * Zval_1 {ref_count:2, value:41, type:LONG}; */ $b ++ ;  /* Context (&quot;a&quot;=> Zval_1, &quot;b&quot; => Zval_2);  * Zval_1 {ref_count:1, value:41, type:LONG};  * Zval_2 {ref_count:1, value:42, type:LONG}; */ $b  .=   &quot;, The answer ...&quot; ;  /* Context (&quot;a&quot;=> Zval_1, &quot;b&quot; => Zval_3);  * Zval_1 {ref_count:1, value:41, type:LONG};  * Zval_2 {ref_count:0, value:42, type:LONG}; // Freed * Zval_3 {ref_count:1, value:&quot;42, The answer ...&quot;, type:STRING}; */
Don't try to outsmart ZE ,[object Object],< ?php $a   =   1 ;  /* Zval {val:1; ref_count:1; is_ref:f} */ $b   =   & $a ;  /* Zval {val:1; ref_count:2; is_ref: t } */ print   ( $b ); /* This is a pass by value function, so, * what's send to print is : * Zval2 {val:1 ref_count:1; is_ref:f } */
Zend Op ,[object Object]
What's in a zend_op ,[object Object]
Op1
Op2

More Related Content

What's hot

PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13julien pauli
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in PerlLaurent Dami
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.VimLin Yo-An
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Nikita Popov
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Joseph Scott
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?Nikita Popov
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codecharsbar
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Lin Yo-An
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation TutorialLorna Mitchell
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Damien Seguy
 
Damien seguy php 5.6
Damien seguy php 5.6Damien seguy php 5.6
Damien seguy php 5.6Damien Seguy
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Nikita Popov
 
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)julien pauli
 

What's hot (20)

PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
 
SPL, not a bridge too far
SPL, not a bridge too farSPL, not a bridge too far
SPL, not a bridge too far
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 code
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
 
Damien seguy php 5.6
Damien seguy php 5.6Damien seguy php 5.6
Damien seguy php 5.6
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)
 
Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
 
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
 

Similar to PHP Performance SfLive 2010

PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machinejulien pauli
 
2010 Smith Scripting101
2010 Smith Scripting1012010 Smith Scripting101
2010 Smith Scripting101bokonen
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from insidejulien pauli
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges✅ William Pinaud
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)David de Boer
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Lucas Witold Adamus
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perldaoswald
 
OPL best practices - Doing more with less easier
OPL best practices - Doing more with less easierOPL best practices - Doing more with less easier
OPL best practices - Doing more with less easierAlex Fleischer
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionIan Barber
 
ES6 Simplified
ES6 SimplifiedES6 Simplified
ES6 SimplifiedCarlos Ble
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perltinypigdotcom
 
More than syntax
More than syntaxMore than syntax
More than syntaxWooga
 
DevOps in PHP environment
DevOps in PHP environmentDevOps in PHP environment
DevOps in PHP environmentEvaldo Felipe
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developersStoyan Stefanov
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly LanguageMotaz Saad
 
Being functional in PHP
Being functional in PHPBeing functional in PHP
Being functional in PHPDavid de Boer
 

Similar to PHP Performance SfLive 2010 (20)

PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machine
 
2010 Smith Scripting101
2010 Smith Scripting1012010 Smith Scripting101
2010 Smith Scripting101
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Php 7 evolution
Php 7 evolutionPhp 7 evolution
Php 7 evolution
 
Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perl
 
OPL best practices - Doing more with less easier
OPL best practices - Doing more with less easierOPL best practices - Doing more with less easier
OPL best practices - Doing more with less easier
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
ES6 Simplified
ES6 SimplifiedES6 Simplified
ES6 Simplified
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perl
 
More than syntax
More than syntaxMore than syntax
More than syntax
 
DevOps in PHP environment
DevOps in PHP environmentDevOps in PHP environment
DevOps in PHP environment
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Being functional in PHP
Being functional in PHPBeing functional in PHP
Being functional in PHP
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

PHP Performance SfLive 2010

  • 1. PHP Performances De Cock Xavier
  • 2.
  • 3.
  • 4.
  • 5.
  • 7.
  • 11.
  • 12.
  • 14. Automatic garbage collection when ref_count is 0
  • 15. As of PHP 5.3 Cyclic garbage collector
  • 16. Zval Examples <?php $a = 41 ; /* Context (&quot;a&quot; => Zval_1); * Zval_1 {ref_count:1, value:41, type:LONG}; */ $b = $a ; /* Context (&quot;a&quot; => Zval_1, &quot;b&quot; => Zval_1); * Zval_1 {ref_count:2, value:41, type:LONG}; */ $b ++ ; /* Context (&quot;a&quot;=> Zval_1, &quot;b&quot; => Zval_2); * Zval_1 {ref_count:1, value:41, type:LONG}; * Zval_2 {ref_count:1, value:42, type:LONG}; */ $b .= &quot;, The answer ...&quot; ; /* Context (&quot;a&quot;=> Zval_1, &quot;b&quot; => Zval_3); * Zval_1 {ref_count:1, value:41, type:LONG}; * Zval_2 {ref_count:0, value:42, type:LONG}; // Freed * Zval_3 {ref_count:1, value:&quot;42, The answer ...&quot;, type:STRING}; */
  • 17.
  • 18.
  • 19.
  • 20. Op1
  • 21. Op2
  • 22. Metas (line n°, handler, result, ...)
  • 23. Opcode examples <?php echo &quot;Hello&quot;, &quot; &quot;, &quot;World&quot;; filename: /home/xavier/- function name: (null) number of ops: 5 compiled vars: none line # op operands --------------------------------------------- 2 0 ECHO OP1[ 'Hello' ] 1 ECHO OP1[ ' ' ] 2 ECHO OP1[ 'World' ] 4 3 RETURN OP1[ 1 ] 4* ZEND_HANDLE_EXCEPTION
  • 24. Opcode examples <?php echo &quot;Hello&quot;.&quot; &quot;.&quot;World&quot;; filename: /home/xavier/- function name: (null) number of ops: 5 compiled vars: none line # op return operands --------------------------------------- 2 0 CONCAT RES[ ~0 ] OP1[ 'Hello' ] OP2[ '+' ] 1 CONCAT RES[ ~1 ] OP1[ ~0 ] OP2[ 'World' ] 2 ECHO OP1[ ~1 ] 3 3 RETURN OP1[ 1 ] 4* ZEND_HANDLE_EXCEPTION
  • 25.
  • 30.
  • 31.
  • 32.
  • 33.
  • 35.
  • 36. SwiftMailer Examples Implementation 1 foreach ( unpack ('C*' , $bytes ) as $byte ) // Convert String to int array { $this -> _array [] = pack ('C' , $byte ); // Function Call in tight loop } filename: /home/xavier/Bureau/php-5.3.1/ext/- function name: (null) number of ops: 17 compiled vars: !0 = $bytes, !1 = $byte line # op return operands ----------------------------------------------- 2 0 SEND_VAL OP1[ 'C*' ] 1 SEND_VAR OP1[ !0 ] 2 DO_FCALL OP1[ 'unpack' ] 3 FE_RESET RES[ $1 ] OP1[ $0 ] OP2[ ->14 ] 4 FE_FETCH RES[ $2 ] OP1[ $1 ] OP2[ ->14 ] 5 ZEND_OP_DATA RES[ UNUSED ] OP1[ UNUSED ] OP2[ UNUSED ] 6 ASSIGN OP1[ !1 ] OP2[ $2 ] 4 7 SEND_VAL OP1[ 'C' ] 8 SEND_VAR OP1[ !1 ] 9 DO_FCALL OP1[ 'pack' ] 10 FETCH_OBJ_W RES[ $4 ] OP1[ UNUSED ] OP2[ '_array' ] 11 ZEND_ASSIGN_DIM OP1[ $4 ] OP2[ UNUSED ] 12 ZEND_OP_DATA RES[ UNUSED ] OP1[ $6 ] OP2[ $7 ] 5 13 JMP OP1[ ->4 ] 14 SWITCH_FREE RES[ UNUSED ] OP1[ $1 ] 6 15 RETURN OP1[ 1 ] 16* ZEND_HANDLE_EXCEPTION
  • 37. SwiftMailer Examples Implementation 2 $to_add = str_split ( $bytes ); // Convert string to char array /* add the array as first arg of the function */ array_unshift ( $to_add , & $this -> _array ); // Will trigger E_STRICT /* Push all elements in one function call and get the count */ $this -> _arraySize = call_user_func_array ('array_push' , $to_add ); compiled vars: !0 = $to_add, !1 = $bytes line # op return operands -------------------------------------------------------------------------- 2 0 SEND_VAR OP1[ !1 ] 1 DO_FCALL OP1[ 'str_split' ] 2 ASSIGN OP1[ !0 ] OP2[ $0 ] 4 3 SEND_REF RES[ UNUSED ] OP1[ !0 ] OP2[ UNUSED ] 4 FETCH_OBJ_W RES[ $2 ] OP1[ UNUSED ] OP2[ '_array' ] 5 SEND_REF RES[ UNUSED ] OP1[ $2 ] OP2[ UNUSED ] 6 DO_FCALL OP1[ 'array_unshift' ] 6 7 SEND_VAL OP1[ 'array_push' ] 8 SEND_VAR OP1[ !0 ] 9 DO_FCALL OP1[ 'call_user_func_array' ] 10 ZEND_ASSIGN_OBJ OP1[ UNUSED ] OP2[ '_arraySize' ] 11 ZEND_OP_DATA RES[ UNUSED ] OP1[ $5 ] OP2[ UNUSED ] 7 12 RETURN OP1[ 1 ] 13* ZEND_HANDLE_EXCEPTION
  • 38. SwiftMailer Examples Implementation 3 $to_add = str_split ( $bytes ); // Convert string to char array /* Calls array Merge */ /* Array merge works by copying the first array element By element, then the second, third, … The speed decreases with the number of items in each array */ $this -> _array = array_merge ( $this -> _array , $to_add ); $this -> _arraySize = count ( $this -> _array ); compiled vars: !0 = $to_add, !1 = $bytes line # op return operands ------------------------------------------------------------------------------- 2 0 SEND_VAR OP1[ !1 ] 1 DO_FCALL OP1[ 'str_split' ] 2 ASSIGN OP1[ !0 ] OP2[ $0 ] 7 3 FETCH_OBJ_R RES[ $3 ] OP1[ UNUSED ] OP2[ '_array' ] 4 SEND_VAR OP1[ $3 ] 5 SEND_VAR OP1[ !0 ] 6 DO_FCALL OP1[ 'array_merge' ] 7 ZEND_ASSIGN_OBJ OP1[ UNUSED ] OP2[ '_array' ] 8 ZEND_OP_DATA RES[ UNUSED ] OP1[ $4 ] OP2[ UNUSED ] 8 9 FETCH_OBJ_R RES[ $6 ] OP1[ UNUSED ] OP2[ '_array' ] 10 SEND_VAR OP1[ $6 ] 11 DO_FCALL OP1[ 'count' ] 12 ZEND_ASSIGN_OBJ OP1[ UNUSED ] OP2[ '_arraySize' ] 13 ZEND_OP_DATA RES[ UNUSED ] OP1[ $7 ] OP2[ UNUSED ] 10 14 RETURN OP1[ 1 ] 15* ZEND_HANDLE_EXCEPTION
  • 39. SwiftMailer Examples Implementation 4 $to_add = str_split ( $bytes ); foreach ( $to_add as $value ) { $this -> _array [] = $value ; } $this -> _arraySize = count ( $this -> _array ); compiled vars: !0 = $to_add, !1 = $bytes, !2 = $value line # op return operands -------------------------------------------------------------------------- 1 0 SEND_VAR OP1[ !1 ] 1 DO_FCALL OP1[ 'str_split' ] 2 ASSIGN OP1[ !0 ] OP2[ $0 ] 2 3 FE_RESET RES[ $2 ] OP1[ !0 ] OP2[ ->11 ] 4 FE_FETCH RES[ $3 ] OP1[ $2 ] OP2[ ->11 ] 5 ZEND_OP_DATA RES[ UNUSED ] OP1[ UNUSED ] OP2[ UNUSED ] 6 ASSIGN OP1[ !2 ] OP2[ $3 ] 3 7 FETCH_OBJ_W RES[ $5 ] OP1[ UNUSED ] OP2[ '_array' ] 8 ZEND_ASSIGN_DIM OP1[ $5 ] OP2[ UNUSED ] 9 ZEND_OP_DATA RES[ UNUSED ] OP1[ !2 ] OP2[ $7 ] 4 10 JMP OP1[ ->4 ] 11 SWITCH_FREE RES[ UNUSED ] OP1[ $2 ] 5 12 FETCH_OBJ_R RES[ $9 ] OP1[ UNUSED ] OP2[ '_array' ] 13 SEND_VAR OP1[ $9 ] 14 DO_FCALL OP1[ 'count' ] 15 ZEND_ASSIGN_OBJ OP1[ UNUSED ] OP2[ '_arraySize' ] 16 ZEND_OP_DATA RES[ UNUSED ] OP1[ $10 ] OP2[ UNUSED ] 6 17 RETURN OP1[ 1 ] 18* ZEND_HANDLE_EXCEPTION
  • 40.
  • 41.
  • 42. Xdebug / Zend Debug – Profilers
  • 43.
  • 44. Use Opcode Caching : APC, eAccelerator, XCache, Zend Server, …
  • 45. Use data Caching : Memcached, …
  • 47. Access your data by batches
  • 49. Use other implementations : Facebook's HipHop, phc, Quercus, RoadSend PHP