com presentations: .: devconf.xml dpc12.xml slides/intro/1992.xml slides/intro/dk.jpg slides/intro/matter2.xml slides/intro/wp1.xml
slides/intro/wp11a.xml slides/intro/wp1a.xml slides/intro/wp1b.xml slides/intro/wp2.xml slides/intro/wp5.xml slides/intro/wp5a.xml
slides/intro/wp6.xml slides/intro/wp6a.xml slides/intro/wp8.xml slides/intro/wp9a.xml slides/intro/wp_xdebug.png
| From: | Rasmus Lerdorf | Date: | Fri, 08 Jun 2012 21:13:24 +0000 |
| Subject: | com presentations: .: devconf.xml dpc12.xml slides/intro/1992.xml slides/intro/dk.jpg slides/intro/matter2.xml slides/intro/wp1.xml slides/intro/wp11a.xml slides/intro/wp1a.xml slides/intro/wp1b.xml slides/intro/wp2.xml slides/intro/wp5.xml slides/intro/wp5a.xml slides/intro/wp6.xml slides/intro/wp6a.xml slides/intro/wp8.xml slides/intro/wp9a.xml slides/intro/wp_xdebug.png |
||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-1812@lists.php.net to get a copy of this message | ||
Commit: 37a82dd9cbafe71103bb8dd98fa4703ad2ae443e
Author: Rasmus Lerdorf <rasmus@php.net> Fri, 8 Jun 2012 23:13:24 +0200
Parents: 2d124079cb2630144a08fad0e89324ed3243fbb2
Branches: master
Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=37a82dd9cbafe71103bb8dd98fa4703ad2ae443e
Log:
.
Changed paths:
A devconf.xml
M dpc12.xml
A slides/intro/1992.xml
A slides/intro/dk..jpg
A slides/intro/matter2.xml
M slides/intro/wp1.xml
A slides/intro/wp11a.xml
A slides/intro/wp1a.xml
A slides/intro/wp1b.xml
M slides/intro/wp2.xml
M slides/intro/wp5.xml
A slides/intro/wp5a.xml
M slides/intro/wp6.xml
A slides/intro/wp6a.xml
M slides/intro/wp8.xml
A slides/intro/wp9a.xml
M slides/intro/wp_xdebug.png
diff --git a/devconf.xml b/devconf.xml new file mode 100644 index 0000000..12751aa --- /dev/null +++ b/devconf.xml @@ -0,0 +1,62 @@ +<presentation + template="simple" + navmode="html" + titlecolor="#000000" + navbarbackground="#bbbbbb" + navbartopiclinks="0" + logo1="images/php-med-trans.png" + titlesize="6em" + navbarheight="3.5em" + examplebackground="#ffffff" + outputbackground="#ffffff" + exampleclass="noshadow" + exampleoutputclass="noshadow" +> +<!-- +Performance +--> + +<topic>PHP</topic> +<title>PHP Performance</title> +<location>Moscow</location> +<date>June 10, 2012</date> +<speaker>Rasmus Lerdorf</speaker> +<url>http://talks.php.net/show/devconf</url> +<twitter>@rasmus</twitter> + +<slide>slides/intro/titlepage.xml</slide> + +<!-- Intro --> +<slide>slides/fowa/hist2.xml</slide> +<slide>slides/fowa/hist3.xml</slide> +<slide>slides/fowa/hist4.xml</slide> +<slide>slides/fowa/hist5.xml</slide> +<slide>slides/intro/php54.xml</slide> + +<!-- Performance --> +<slide>slides/intro/perf_overall1.xml</slide> +<slide>slides/intro/wp1.xml</slide> +<slide>slides/intro/wp1a.xml</slide> +<slide>slides/intro/wp1b.xml</slide> +<slide>slides/intro/wp2.xml</slide> +<slide>slides/intro/wp3.xml</slide> +<slide>slides/intro/wp4.xml</slide> +<slide>slides/intro/wp5.xml</slide> +<slide>slides/intro/wp5a.xml</slide> +<slide>slides/intro/wp6a.xml</slide> +<slide>slides/intro/wp7.xml</slide> +<slide>slides/intro/wp8.xml</slide> +<slide>slides/intro/wp9a.xml</slide> +<slide>slides/intro/wp10.xml</slide> +<slide>slides/intro/wp11a.xml</slide> +<slide>slides/intro/wp12.xml</slide> +<slide>slides/intro/hiphop.xml</slide> + +<slide>slides/intro/ntwit0.xml</slide> +<slide>slides/intro/ntwit1.xml</slide> +<slide>slides/intro/ntwit2.xml</slide> +<slide>slides/intro/ntwit3.xml</slide> +<slide>slides/intro/ntwit4.xml</slide> +<slide>slides/intro/perf_conclusion.xml</slide> + +</presentation> diff --git a/dpc12.xml b/dpc12.xml index 9c58eba..9ebdc95 100644 --- a/dpc12.xml +++ b/dpc12.xml @@ -45,9 +45,11 @@ Future direction <!-- Intro --> +<slide>slides/intro/1992.xml</slide> <slide>slides/intro/php_slideshow.xml</slide> <slide>slides/intro/matter.xml</slide> +<slide>slides/intro/matter2.xml</slide> <slide>slides/intro/ecosystem.xml</slide> @@ -56,6 +58,7 @@ Future direction <slide>slides/intro/eventmq.xml</slide> <slide>slides/intro/eventmq2.xml</slide> <slide>slides/intro/svm.xml</slide> +<slide>slides/intro/future3.xml</slide> <slide>slides/intro/contrib0.xml</slide> <slide>slides/intro/contrib1.xml</slide> @@ -66,7 +69,6 @@ Future direction <slide>slides/intro/contrib6.xml</slide> <slide>slides/intro/contrib7.xml</slide> -<slide>slides/intro/future3.xml</slide> <slide>slides/intro/key_matter.xml</slide> </presentation> diff --git a/slides/intro/1992.xml b/slides/intro/1992.xml new file mode 100644 index 0000000..20d03ca --- /dev/null +++ b/slides/intro/1992.xml @@ -0,0 +1,4 @@ +<slide title=""> +<blurb fontsize="16em" align="center">1992</blurb> +<image align="center" filename="dk.jpg"/> +</slide> diff --git a/slides/intro/dk.jpg b/slides/intro/dk.jpg new file mode 100644 index 0000000..6578323 Binary files /dev/null and b/slides/intro/dk.jpg differ diff --git a/slides/intro/matter2.xml b/slides/intro/matter2.xml new file mode 100644 index 0000000..f07e78d --- /dev/null +++ b/slides/intro/matter2.xml @@ -0,0 +1,4 @@ +<slide title=""> +<break lines="12"/> +<blurb fontsize="5em" align="center">We are running out of things that can be solved in isolation with our keyboards</blurb> +</slide> diff --git a/slides/intro/wp1.xml b/slides/intro/wp1.xml index 7e7ac81..1387445 100644 --- a/slides/intro/wp1.xml +++ b/slides/intro/wp1.xml @@ -1,26 +1,27 @@ -<slide title="Current Wordpress SVN Checkout"> +<slide title="Wordpress"> <break lines="1" /> <link fontsize="3em" marginleft="1em" leader="Siege: " href="http://www.joedog.org/JoeDog/Siege"/> -<example fontsize="1.4em" type="shell" title="Baseline Benchmark Wordpress PHP-5.3.3-dev Apache-2.2.12 prefork"><![CDATA[ -|0077aa|~>| *siege -c 5 -b -t30s http://wp1.localhost* -** SIEGE 2.68 +<example fontsize="1.4em" type="shell" title="Baseline Benchmark Wordpress-svn PHP-5.3.15-dev Apache-2.2.22 prefork"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp1.localhost/?p=1"* +** SIEGE 2.70 ** Preparing 5 concurrent users for battle. The server is now under siege... -Lifting the server siege... done. -Transactions: 258 hits +Lifting the server siege.. done. +Transactions: 579 hits Availability: 100.00 % -Elapsed time: 29.56 secs -Data transferred: 0.55 MB -Response time: *0.57 secs* -Transaction rate: *8.73 trans/sec* -Throughput: 0.02 MB/sec -Concurrency: 4.95 -Successful transactions: 258 +Elapsed time: 29.41 secs +Data transferred: 4.68 MB +Response time: *0.25 secs* +Transaction rate: *19.69 trans/sec* +Throughput: 0.16 MB/sec +Concurrency: 4.98 +Successful transactions: 579 Failed transactions: 0 -Longest transaction: 1.10 -Shortest transaction: 0.26]]></example> +Longest transaction: 0.51 +Shortest transaction: 0.14 +]]></example> </slide> diff --git a/slides/intro/wp11a.xml b/slides/intro/wp11a.xml new file mode 100644 index 0000000..21d73df --- /dev/null +++ b/slides/intro/wp11a.xml @@ -0,0 +1,27 @@ +<slide title="Add cache to locate_template()"> + +<blurb fontsize="3.5em"> +The *locate_template()* function checks stats the filesystem on every call to find templates. +Cache these stats in shared memory. +</blurb> + +<example fontsize="1.4em" type="shell" title=""><![CDATA[ +|0077aa|~>| *siege -b -t30s -c5 http://wp1.localhost* +** SIEGE 2.70 +** Preparing 5 concurrent users for battle. +The server is now under siege... +Lifting the server siege.. done. +Transactions: 2408 hits +Availability: 100.00 % +Elapsed time: 29.46 secs +Data transferred: 19.45 MB +Response time: *0.06 secs* +Transaction rate: *81.74 trans/sec* +Throughput: 0.66 MB/sec +Concurrency: 4.99 +Successful transactions: 2408 +Failed transactions: 0 +Longest transaction: 0.12 +Shortest transaction: 0.02]]></example> + +</slide> diff --git a/slides/intro/wp1a.xml b/slides/intro/wp1a.xml new file mode 100644 index 0000000..967e3eb --- /dev/null +++ b/slides/intro/wp1a.xml @@ -0,0 +1,27 @@ +<slide title="Wordpress"> + +<break lines="1" /> + +<link fontsize="3em" marginleft="1em" leader="Siege: " href="http://www.joedog.org/JoeDog/Siege"/> + +<example fontsize="1.4em" type="shell" title="Baseline Benchmark Wordpress-svn PHP-5.4.5-dev Apache-2.2.22 prefork"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp1.localhost/?p=1"* +** SIEGE 2.70 +** Preparing 5 concurrent users for battle. +The server is now under siege... +Lifting the server siege.. done. +Transactions: 670 hits +Availability: 100.00 % +Elapsed time: 29.61 secs +Data transferred: 5.41 MB +Response time: *0.22 secs* +Transaction rate: *22.63 trans/sec* +Throughput: 0.18 MB/sec +Concurrency: 4.98 +Successful transactions: 670 +Failed transactions: 0 +Longest transaction: 0.35 +Shortest transaction: 0.14 +]]></example> + +</slide> diff --git a/slides/intro/wp1b.xml b/slides/intro/wp1b.xml new file mode 100644 index 0000000..aa39a51 --- /dev/null +++ b/slides/intro/wp1b.xml @@ -0,0 +1,27 @@ +<slide title="Wordpress"> + +<break lines="1" /> + +<link fontsize="3em" marginleft="1em" leader="Siege: " href="http://www.joedog.org/JoeDog/Siege"/> + +<example fontsize="1.4em" type="shell" title="Baseline Benchmark Wordpress-svn PHP-FPM-5.4.5-dev nginx-1.1.19"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp1.localhost/?p=1"* +** SIEGE 2.70 +** Preparing 5 concurrent users for battle. +The server is now under siege... +Lifting the server siege.. done. +Transactions: 659 hits +Availability: 100.00 % +Elapsed time: 29.02 secs +Data transferred: 5.32 MB +Response time: *0.22 secs* +Transaction rate: *22.71 trans/sec* +Throughput: 0.18 MB/sec +Concurrency: 4.97 +Successful transactions: 659 +Failed transactions: 0 +Longest transaction: 1.62 +Shortest transaction: 0.13 +]]></example> + +</slide> diff --git a/slides/intro/wp2.xml b/slides/intro/wp2.xml index 2c9a86a..7687751 100644 --- a/slides/intro/wp2.xml +++ b/slides/intro/wp2.xml @@ -4,26 +4,25 @@ <link fontsize="3em" marginleft="1em" leader="APC: " href="http://pecl.php.net/APC"/> -<example fontsize="1.4em" title="Set your default timezone in php.ini file"><![CDATA[date.timezone = "America/Los_Angeles"]]></example> - -<example fontsize="1.4em" type="shell" title="Benchmarking PHP-5.3.3-dev w/ APC-3.1.4-dev zend.enable_gc=Off"><![CDATA[ -|0077aa|~>| *siege -c 5 -b -t30s http://wp1.localhost* -** SIEGE 2.68 +<example fontsize="1.4em" type="shell" title="Benchmarking PHP-5.4.5-dev w/ APC-3.1.11-dev --enable-apc-pthreadrwlocks"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp1.localhost/?p=1"* +** SIEGE 2.70 ** Preparing 5 concurrent users for battle. The server is now under siege... -Lifting the server siege... done. -Transactions: 788 hits +Lifting the server siege.. done. +Transactions: 2259 hits Availability: 100.00 % -Elapsed time: 29.27 secs -Data transferred: 1.66 MB -Response time: *0.18 secs* -Transaction rate: *26.92 trans/sec* -Throughput: 0.06 MB/sec -Concurrency: 4.97 -Successful transactions: 788 +Elapsed time: 29.70 secs +Data transferred: 18.24 MB +Response time: *0.07 secs* +Transaction rate: *76.06 trans/sec* +Throughput: 0.61 MB/sec +Concurrency: 4.99 +Successful transactions: 2259 Failed transactions: 0 -Longest transaction: 0.65 -Shortest transaction: 0.07]]></example> +Longest transaction: 0.13 +Shortest transaction: 0.03 +]]></example> <example title="Make sure we are cpu-bound" fontsize="1.3em" type="shell"> |0077aa|~>| *vmstat 1* diff --git a/slides/intro/wp5.xml b/slides/intro/wp5.xml index cdd8978..1721f0c 100644 --- a/slides/intro/wp5.xml +++ b/slides/intro/wp5.xml @@ -4,125 +4,136 @@ <example fontsize="1.4em" type="shell" title="Check for open() syscalls"><![CDATA[ |0077aa|~>| *grep open strace.out* -open("/var/www/wp1/wp-load.php", O_RDONLY) = 29 -open("/var/www/wp1/wp-config.php", O_RDONLY) = 29 -open("/var/www/wp1/wp-settings.php", O_RDONLY) = 29 -open("/var/www/wp1/wp-includes/wp-db.php", O_RDONLY) = 29 -open("/var/www/wp1/wp-includes/cache.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/pomo/translations.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/pomo/entry.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/pomo/streams.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/default-widgets.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/default-embeds.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/template-loader.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/header.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/sidebar.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/footer.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/style.css", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickbgcolor.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickbg-ltr.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickheader.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickfooter.jpg", O_RDONLY) = 29]]></example> +open("/var/www/wp1/wp-load.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-config.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-settings.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/pomo/translations.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/pomo/entry.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/pomo/streams.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/wp-db.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/cache.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-includes/l10n.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-includes/default-widgets.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-includes/locale.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-includes/template-loader.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-content/themes/twentyeleven/header.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-content/themes/twentyeleven/style.css", O_RDONLY) = 28 +open("/var/www/wp1/wp-content/themes/twentyeleven/footer.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-content/themes/twentyeleven/sidebar-footer.php", O_RDONLY) = 28 +]]></example> <example fontsize="1em" title="Conditional config include in wp-load.php"><![CDATA[<?php if ( file_exists( ABSPATH . 'wp-config.php') ) { - /** The config file resides in ABSPATH */ - require_once( ABSPATH . 'wp-config.php' ); + + /** The config file resides in ABSPATH */ + require_once( ABSPATH . 'wp-config.php' ); } elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) && ! file_exists( dirname(ABSPATH) . '/wp-settings.php' ) ) { - /** The config file resides one level above ABSPATH but is not part of another install*/ - require_once( dirname(ABSPATH) . '/wp-config.php' ); + + /** The config file resides one level above ABSPATH but is not part of another install */ + require_once( dirname(ABSPATH) . '/wp-config.php' ); + } else { - // A config file doesn't exist - // Set a path for the link to the installer - if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; - else $path = 'wp-admin/'; - - // Die with an error message - require_once( ABSPATH . '/wp-includes/classes.php' ); - require_once( ABSPATH . '/wp-includes/functions.php' ); - require_once( ABSPATH . '/wp-includes/plugin.php' ); - $text_direction = /*WP_I18N_TEXT_DIRECTION*/"ltr"/*/WP_I18N_TEXT_DIRECTION*/; - wp_die(sprintf(/*WP_I18N_NO_CONFIG*/"There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can ge -t started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can create a <code>wp-config -.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file. -</p><p><a href='%ssetup-config.php' class='button'>Create a Configuration File</a>"/*/WP_I18N_NO_CONFIG*/, $path), /*WP_I18N_ERROR_TI -TLE*/"WordPress › Error"/*/WP_I18N_ERROR_TITLE*/, array('text_direction' => $text_direction)); -} -?>]]></example> + + // A config file doesn't exist + + // Set a path for the link to the installer + if ( strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false ) + $path = 'setup-config.php'; + else + $path = 'wp-admin/setup-config.php'; + + define( 'WPINC', 'wp-includes' ); + define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); + require_once( ABSPATH . WPINC . '/load.php' ); + require_once( ABSPATH . WPINC . '/version.php' ); + + wp_load_translations_early(); + wp_check_php_mysql_versions(); + + // Die with an error message + $die = __( "There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started." ) . '</p>'; + $die .= '<p>' . __( "Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>." ) . '</p>'; + $die .= '<p>' . __( "You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file." ) . '</p>'; + $die .= '<p><a href="' . $path . '" class="button">' . __( "Create a Configuration File" ) . '</a>'; + + wp_die( $die, __( 'WordPress › Error' ) ); +}]]></example> <example fontsize="1.4em" title="Replace with"><![CDATA[<?php -include './wp-config.php'; -?>]]></example> +include './wp-config.php';]]></example> + +<example fontsize="1.4em" title="Get rid of require_once of wp-settings.php in wp-config.php"><![CDATA[<?php +#require_once(ABSPATH . 'wp-settings.php'); +require './wp-settings.php';]]></example> + +<example fontsize="1.4em" title="Get rid of require_once calls in wp-settings.php"><![CDATA[<?php +#require_once( ABSPATH . WPINC . '/l10n.php' ) +require './wp-includes/l10n.php'; +... +require_once( ABSPATH . WPINC . '/locale.php' ); +require './wp-includes/locale.php';]]></example> <example fontsize="1.4em" title="Conditional did-header check in wp-blog-header.php"><![CDATA[<?php #if ( !isset($wp_did_header) ) { - $wp_did_header = true; - require_once( dirname(__FILE__) . '/wp-load.php' ); - wp(); - require_once( ABSPATH . WPINC . '/template-loader.php' ); +# $wp_did_header = true; +# require_once( dirname(__FILE__) . '/wp-load.php' ); +# wp(); +# require_once( ABSPATH . WPINC . '/template-loader.php' ); #} +require './wp-load.php'; +wp(); +require './wp-includes/template-loader.php'; ?>]]></example> -<example fontsize="1.4em" title="require_wp_db() call in wp-includes/functions.php"><![CDATA[<?php +<example fontsize="1.4em" title="require_wp_db() call in wp-includes/load.php"><![CDATA[<?php function require_wp_db() { - global $wpdb; - if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) - require_once( WP_CONTENT_DIR . '/db.php' ); - else - require_once( ABSPATH . WPINC . '/wp-db.php' ); -} -?>]]></example> + global $wpdb; + + require_once( ABSPATH . WPINC . '/wp-db.php' ); + if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) + require_once( WP_CONTENT_DIR . '/db.php' ); + + if ( isset( $wpdb ) ) + return; + + $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); +}]]></example> <example fontsize="1.4em" title="Don't call require_wp_db() from wp-settings.php"><![CDATA[<?php #require_wp_db(); require './wp-includes/wp-db.php'; +$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); ]]></example> <example fontsize="1.4em" title="Hardcode built-in wp cache in wp-settings.php"><![CDATA[<?php require './wp-includes/cache.php'; +$_wp_using_ext_object_cache = false; +wp_cache_init(); +wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) ); +wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); +#wp_start_object_cache(); ]]></example> -<example fontsize="1.4em" title="Remove conditional require logic from wp_start_object_cache"><![CDATA[<?php -function wp_start_object_cache() { - global $_wp_using_ext_object_cache; - $first_init = false; - $_wp_using_ext_object_cache = false; - static $first_init = true; - -# if ( ! function_exists( 'wp_cache_init' ) ) { -# global $_wp_using_ext_object_cache; -# if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { -# require_once ( WP_CONTENT_DIR . '/object-cache.php' ); -# $_wp_using_ext_object_cache = true; -# } else { -# require_once ( ABSPATH . WPINC . '/cache.php' ); -# $_wp_using_ext_object_cache = false; -# } -# $first_init = true; -# } -...]]></example> +<example fontsize="1.4em" title="PHP 5.3 has a __DIR__ constant - use in wp-load.php"><![CDATA[<?php +#define( 'ABSPATH', dirname(__FILE__) . '/' ); +define( 'ABSPATH', __DIR__ . '/' ); +]]></example> <example fontsize="1.4em" type="shell" title="Check again"><![CDATA[ |0077aa|~>| *grep open strace2.out* -open("/var/www/wp2/wp-includes/pomo/translations.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/pomo/entry.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/pomo/streams.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/default-widgets.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/default-embeds.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/template-loader.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-content/themes/default/header.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-content/themes/default/sidebar.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-content/themes/default/footer.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/style.css", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickbgcolor.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickbg-ltr.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickheader.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickfooter.jpg", O_RDONLY) = 29 +open("/var/www/wp2/wp-includes/pomo/translations.php", O_RDONLY) = 27 +open("/var/www/wp2/wp-includes/pomo/entry.php", O_RDONLY) = 27 +open("/var/www/wp2/wp-includes/pomo/streams.php", O_RDONLY) = 27 +open("/var/www/wp2/wp-includes/default-widgets.php", O_RDONLY) = 28 +open("/var/www/wp2/wp-content/themes/twentyeleven/header.php", O_RDONLY) = 28 +open("/var/www/wp2/wp-content/themes/twentyeleven/style.css", O_RDONLY) = 28 +open("/var/www/wp2/wp-content/themes/twentyeleven/footer.php", O_RDONLY) = 28 +open("/var/www/wp2/wp-content/themes/twentyeleven/sidebar-footer.php", O_RDONLY) = 28 ]]></example> <blurb fontsize="3em"> -We just have translations, plugins and themes left here now. We could hardcode these as +We just have translations, plugin widgets and themes left here now. We could hardcode these as well, but then we start to lose the main characteristics of Wordpress. </blurb> </slide> diff --git a/slides/intro/wp5a.xml b/slides/intro/wp5a.xml new file mode 100644 index 0000000..8c2102e --- /dev/null +++ b/slides/intro/wp5a.xml @@ -0,0 +1,25 @@ +<slide title="Benchmark again"> + +<break lines="1" /> + +<example fontsize="1.4em" type="shell" title="Benchmarking PHP-5.4.5-dev w/ APC-3.1.11-dev --enable-apc-pthreadrwlocks"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp2.localhost/?p=1"* +** SIEGE 2.70 +** Preparing 5 concurrent users for battle. +The server is now under siege... +Lifting the server siege.. done. +Transactions: 2331 hits +Availability: 100.00 % +Elapsed time: 29.40 secs +Data transferred: 18.82 MB +Response time: *0.06 secs* +Transaction rate: *79.29 trans/sec* +Throughput: 0.64 MB/sec +Concurrency: 4.99 +Successful transactions: 2331 +Failed transactions: 0 +Longest transaction: 0.12 +Shortest transaction: 0.02 +]]></example> + +</slide> diff --git a/slides/intro/wp6.xml b/slides/intro/wp6.xml index 98be1c5..e796734 100644 --- a/slides/intro/wp6.xml +++ b/slides/intro/wp6.xml @@ -3,7 +3,8 @@ <break lines="1" /> <blurb fontsize="3.5em"> -Set *error_reporting(-1)* in *wp-settings.php* to catch all warnings +Set *error_reporting(-1)* in *wp-load.php* and *wp-includes/load.php* to catch all warnings. +Wordpress has fixed all of them in the current version. Previously we saw warnings like this: </blurb> <example fontsize="0.8em" type="shell" title=""><![CDATA[ diff --git a/slides/intro/wp6a.xml b/slides/intro/wp6a.xml new file mode 100644 index 0000000..9b62535 --- /dev/null +++ b/slides/intro/wp6a.xml @@ -0,0 +1,33 @@ +<slide title="Fix all warnings"> + +<break lines="1" /> + +<blurb fontsize="3em"> +Set *error_reporting(-1)* in *wp-load.php* and *wp-includes/load.php* to catch all warnings. +Wordpress has fixed most of them in the current version. +</blurb> + +<example fontsize="0.8em" type="shell" title=""><![CDATA[ + +Strict Standards: Redefining already defined constructor for class WP_Widget in /var/www/wp2/wp-includes/widgets.php on line 93 + +]]></example> + +<example fontsize="1.4em" title="Stray PHP4 constructor"><![CDATA[<?php +/** + * PHP4 constructor + */ +function WP_Widget( $id_base = false, $name, $widget_options = array(), $control_options = array() ) { + WP_Widget::__construct( $id_base, $name, $widget_options, $control_options ); +} +]]></example> + +<break lines="1"/> + +<example fontsize="0.8em" type="shell" title=""><![CDATA[ + +Fatal error: Call to undefined method Twenty_Eleven_Ephemera_Widget::WP_Widget() in /var/www/wp2/wp-content/themes/twentyeleven/inc/widgets.php on line 20 + +]]></example> + +</slide> diff --git a/slides/intro/wp8.xml b/slides/intro/wp8.xml index 28382ef..1aa5eac 100644 --- a/slides/intro/wp8.xml +++ b/slides/intro/wp8.xml @@ -11,6 +11,6 @@ xdebug.profiler_output_dir=/tmp]]></example> <example fontsize="2em" type="shell"><![CDATA[|0077aa|~>| *kcachegrind cachegrind.out.\**]]></example> -<image filename="wp_xdebug.png" width="1003" height="597" align="center"/> +<image filename="wp_xdebug.png" width="1022" height="596" align="center"/> </slide> diff --git a/slides/intro/wp9a.xml b/slides/intro/wp9a.xml new file mode 100644 index 0000000..21fe022 --- /dev/null +++ b/slides/intro/wp9a.xml @@ -0,0 +1,102 @@ +<slide title="Check xhprof"> + +<break lines="1" /> +<example fontsize="1.4em" type="shell" title="pecl/xhprof extension in php.ini"><![CDATA[extension=xhprof.so +xhprof.output_dir=/tmp]]></example> + +<example fontsize="1.4em" type="shell" title="xhprof vhost"><![CDATA[<VirtualHost *:80> + ServerName xhprof.localhost + UseCanonicalName Off + DocumentRoot /var/www/xhprof + ErrorLog /var/log/apache2/xhprof-error.log + CustomLog /var/log/apache2/xhprof-access.log combined + DirectoryIndex index.php index.html +</VirtualHost>]]></example> + +<example fontsize="1.4em" type="shell" title="enable xhprof for a vhost"><![CDATA[ +# For XHPROF Profiling + php_value auto_prepend_file /var/www/xhprof/header.php + php_value auto_append_file /var/www/xhprof/footer.php +...]]></example> + +<example fontsize="1.4em" title="header.php"><![CDATA[<?php +include '/var/www/xhprof/xhprof_lib/utils/xhprof_lib.php'; +include '/var/www/xhprof/xhprof_lib/utils/xhprof_runs.php'; +xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);]]></example> + +<example fontsize="1.4em" title="footer.php"><![CDATA[<?php +$app = $_SERVER['HTTP_HOST']; +$xhprof_data = xhprof_disable(); +$xhprof_runs = new XHProfRuns_Default(); +$id = $xhprof_runs->save_run($xhprof_data, $app); +$ua = urlencode($app); +$profiler_url = "http://xhprof.localhost/index.php?run=$id&source=$ua"; +echo '<a href="'. $profiler_url .'" target="_blank">Profiler output</a>';]]></example> + +<blurb fontsize="3.5em"> +Now hit the server a few times to warm up the caches, then click the "Profiler Output" link at the bottom. +</blurb> + +<example fontsize="1.25em" type="shell" title="mysql_connect and mysql_set_charset"><![CDATA[ +--- wp-db.php (revision 13595) ++++ wp-db.php (working copy) +@@ -499,7 +499,7 @@ +- $this->dbh = *@mysql_connect*( $dbhost, $dbuser, $dbpassword, *true* ); ++ $this->dbh = *mysql_pconnect*( $dbhost, $dbuser, $dbpassword ); +@@ -518,7 +516,7 @@ +- mysql_set_charset( $this->charset, $this->dbh ); ++# mysql_set_charset( $this->charset, $this->dbh ); +]]></example> + +<blurb fontsize="2.5em"> +And as we are browsing the source code, we can replace most *time()* calls with *$_SERVER['REQUEST_TIME']* and also any +*date()* or *gmdate()* calls that don't already have a timestamp argument, we can add *$_SERVER['REQUEST_TIME']* to those. +</blurb> + +<example fontsize="1em" type="shell" title="$_SERVER['REQUEST_TIME'] example"><![CDATA[--- ./load.php 2010-03-05 09:31:16.573829617 -0800 ++++ ../../wp2/wp-includes/load.php 2010-03-05 16:57:13.452580398 -0800 +@@ -138,7 +138,7 @@ +- if ( ( *time()* - $upgrading ) >= 600 ) ++ if ( ( *$_SERVER['REQUEST_TIME']* - $upgrading ) >= 600 ) +]]></example> + +<blurb fontsize="3.5em"> +And finally, let's disable the phone-home version update check and the cron functionality. +We can do these out-of-band ourselves. +</blurb> + +<example fontsize="1em" type="shell" title="Disable cron and update check"><![CDATA[... +Index: wp-settings.php +=================================================================== +--- wp-settings.php (revision 13594) ++++ wp-settings.php (working copy) +@@ -118,11 +117,11 @@ + require( ABSPATH . WPINC . '/bookmark.php' ); + require( ABSPATH . WPINC . '/bookmark-template.php' ); + require( ABSPATH . WPINC . '/kses.php' ); +-require( ABSPATH . WPINC . '/cron.php' ); ++*#*require( ABSPATH . WPINC . '/cron.php' ); + require( ABSPATH . WPINC . '/deprecated.php' ); + require( ABSPATH . WPINC . '/script-loader.php' ); + require( ABSPATH . WPINC . '/taxonomy.php' ); +-require( ABSPATH . WPINC . '/update.php' ); ++*#*require( ABSPATH . WPINC . '/update.php' ); + require( ABSPATH . WPINC . '/canonical.php' ); + require( ABSPATH . WPINC . '/shortcodes.php' ); + require( ABSPATH . WPINC . '/media.php' ); + +Index: default-filters.php +=================================================================== +--- default-filters.php (revision 13595) ++++ default-filters.php (working copy) +@@ -198,8 +198,8 @@ + } + + // WP Cron +-if ( !defined( 'DOING_CRON' ) ) +- add_action( 'sanitize_comment_cookies', 'wp_cron' ); ++*#*if ( !defined( 'DOING_CRON' ) ) ++*#* add_action( 'sanitize_comment_cookies', 'wp_cron' ); +]]></example> + +</slide> diff --git a/slides/intro/wp_xdebug.png b/slides/intro/wp_xdebug.png index b4789da..ec35283 100644 Binary files a/slides/intro/wp_xdebug.png and b/slides/intro/wp_xdebug.png differ
diff --git a/devconf.xml b/devconf.xml new file mode 100644 index 0000000..12751aa --- /dev/null +++ b/devconf.xml @@ -0,0 +1,62 @@ +<presentation + template="simple" + navmode="html" + titlecolor="#000000" + navbarbackground="#bbbbbb" + navbartopiclinks="0" + logo1="images/php-med-trans.png" + titlesize="6em" + navbarheight="3.5em" + examplebackground="#ffffff" + outputbackground="#ffffff" + exampleclass="noshadow" + exampleoutputclass="noshadow" +> +<!-- +Performance +--> + +<topic>PHP</topic> +<title>PHP Performance</title> +<location>Moscow</location> +<date>June 10, 2012</date> +<speaker>Rasmus Lerdorf</speaker> +<url>http://talks.php.net/show/devconf</url> +<twitter>@rasmus</twitter> + +<slide>slides/intro/titlepage.xml</slide> + +<!-- Intro --> +<slide>slides/fowa/hist2.xml</slide> +<slide>slides/fowa/hist3.xml</slide> +<slide>slides/fowa/hist4.xml</slide> +<slide>slides/fowa/hist5.xml</slide> +<slide>slides/intro/php54.xml</slide> + +<!-- Performance --> +<slide>slides/intro/perf_overall1.xml</slide> +<slide>slides/intro/wp1.xml</slide> +<slide>slides/intro/wp1a.xml</slide> +<slide>slides/intro/wp1b.xml</slide> +<slide>slides/intro/wp2.xml</slide> +<slide>slides/intro/wp3.xml</slide> +<slide>slides/intro/wp4.xml</slide> +<slide>slides/intro/wp5.xml</slide> +<slide>slides/intro/wp5a.xml</slide> +<slide>slides/intro/wp6a.xml</slide> +<slide>slides/intro/wp7.xml</slide> +<slide>slides/intro/wp8.xml</slide> +<slide>slides/intro/wp9a.xml</slide> +<slide>slides/intro/wp10.xml</slide> +<slide>slides/intro/wp11a.xml</slide> +<slide>slides/intro/wp12.xml</slide> +<slide>slides/intro/hiphop.xml</slide> + +<slide>slides/intro/ntwit0.xml</slide> +<slide>slides/intro/ntwit1.xml</slide> +<slide>slides/intro/ntwit2.xml</slide> +<slide>slides/intro/ntwit3.xml</slide> +<slide>slides/intro/ntwit4.xml</slide> +<slide>slides/intro/perf_conclusion.xml</slide> + +</presentation> diff --git a/dpc12.xml b/dpc12.xml index 9c58eba..9ebdc95 100644 --- a/dpc12.xml +++ b/dpc12.xml @@ -45,9 +45,11 @@ Future direction <!-- Intro --> +<slide>slides/intro/1992.xml</slide> <slide>slides/intro/php_slideshow.xml</slide> <slide>slides/intro/matter.xml</slide> +<slide>slides/intro/matter2.xml</slide> <slide>slides/intro/ecosystem.xml</slide> @@ -56,6 +58,7 @@ Future direction <slide>slides/intro/eventmq.xml</slide> <slide>slides/intro/eventmq2.xml</slide> <slide>slides/intro/svm.xml</slide> +<slide>slides/intro/future3.xml</slide> <slide>slides/intro/contrib0.xml</slide> <slide>slides/intro/contrib1.xml</slide> @@ -66,7 +69,6 @@ Future direction <slide>slides/intro/contrib6.xml</slide> <slide>slides/intro/contrib7.xml</slide> -<slide>slides/intro/future3.xml</slide> <slide>slides/intro/key_matter.xml</slide> </presentation> diff --git a/slides/intro/1992.xml b/slides/intro/1992.xml new file mode 100644 index 0000000..20d03ca --- /dev/null +++ b/slides/intro/1992.xml @@ -0,0 +1,4 @@ +<slide title=""> +<blurb fontsize="16em" align="center">1992</blurb> +<image align="center" filename="dk.jpg"/> +</slide> diff --git a/slides/intro/dk.jpg b/slides/intro/dk.jpg new file mode 100644 index 0000000..6578323 Binary files /dev/null and b/slides/intro/dk.jpg differ diff --git a/slides/intro/matter2.xml b/slides/intro/matter2.xml new file mode 100644 index 0000000..f07e78d --- /dev/null +++ b/slides/intro/matter2.xml @@ -0,0 +1,4 @@ +<slide title=""> +<break lines="12"/> +<blurb fontsize="5em" align="center">We are running out of things that can be solved in isolation with our keyboards</blurb> +</slide> diff --git a/slides/intro/wp1.xml b/slides/intro/wp1.xml index 7e7ac81..1387445 100644 --- a/slides/intro/wp1.xml +++ b/slides/intro/wp1.xml @@ -1,26 +1,27 @@ -<slide title="Current Wordpress SVN Checkout"> +<slide title="Wordpress"> <break lines="1" /> <link fontsize="3em" marginleft="1em" leader="Siege: " href="http://www.joedog.org/JoeDog/Siege"/> -<example fontsize="1.4em" type="shell" title="Baseline Benchmark Wordpress PHP-5.3.3-dev Apache-2.2.12 prefork"><![CDATA[ -|0077aa|~>| *siege -c 5 -b -t30s http://wp1.localhost* -** SIEGE 2.68 +<example fontsize="1.4em" type="shell" title="Baseline Benchmark Wordpress-svn PHP-5.3.15-dev Apache-2.2.22 prefork"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp1.localhost/?p=1"* +** SIEGE 2.70 ** Preparing 5 concurrent users for battle. The server is now under siege... -Lifting the server siege... done. -Transactions: 258 hits +Lifting the server siege.. done. +Transactions: 579 hits Availability: 100.00 % -Elapsed time: 29.56 secs -Data transferred: 0.55 MB -Response time: *0.57 secs* -Transaction rate: *8.73 trans/sec* -Throughput: 0.02 MB/sec -Concurrency: 4.95 -Successful transactions: 258 +Elapsed time: 29.41 secs +Data transferred: 4.68 MB +Response time: *0.25 secs* +Transaction rate: *19.69 trans/sec* +Throughput: 0.16 MB/sec +Concurrency: 4.98 +Successful transactions: 579 Failed transactions: 0 -Longest transaction: 1.10 -Shortest transaction: 0.26]]></example> +Longest transaction: 0.51 +Shortest transaction: 0.14 +]]></example> </slide> diff --git a/slides/intro/wp11a.xml b/slides/intro/wp11a.xml new file mode 100644 index 0000000..21d73df --- /dev/null +++ b/slides/intro/wp11a.xml @@ -0,0 +1,27 @@ +<slide title="Add cache to locate_template()"> + +<blurb fontsize="3.5em"> +The *locate_template()* function checks stats the filesystem on every call to find templates. +Cache these stats in shared memory. +</blurb> + +<example fontsize="1.4em" type="shell" title=""><![CDATA[ +|0077aa|~>| *siege -b -t30s -c5 http://wp1.localhost* +** SIEGE 2.70 +** Preparing 5 concurrent users for battle. +The server is now under siege... +Lifting the server siege.. done. +Transactions: 2408 hits +Availability: 100.00 % +Elapsed time: 29.46 secs +Data transferred: 19.45 MB +Response time: *0.06 secs* +Transaction rate: *81.74 trans/sec* +Throughput: 0.66 MB/sec +Concurrency: 4.99 +Successful transactions: 2408 +Failed transactions: 0 +Longest transaction: 0.12 +Shortest transaction: 0.02]]></example> + +</slide> diff --git a/slides/intro/wp1a.xml b/slides/intro/wp1a.xml new file mode 100644 index 0000000..967e3eb --- /dev/null +++ b/slides/intro/wp1a.xml @@ -0,0 +1,27 @@ +<slide title="Wordpress"> + +<break lines="1" /> + +<link fontsize="3em" marginleft="1em" leader="Siege: " href="http://www.joedog.org/JoeDog/Siege"/> + +<example fontsize="1.4em" type="shell" title="Baseline Benchmark Wordpress-svn PHP-5.4.5-dev Apache-2.2.22 prefork"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp1.localhost/?p=1"* +** SIEGE 2.70 +** Preparing 5 concurrent users for battle. +The server is now under siege... +Lifting the server siege.. done. +Transactions: 670 hits +Availability: 100.00 % +Elapsed time: 29.61 secs +Data transferred: 5.41 MB +Response time: *0.22 secs* +Transaction rate: *22.63 trans/sec* +Throughput: 0.18 MB/sec +Concurrency: 4.98 +Successful transactions: 670 +Failed transactions: 0 +Longest transaction: 0.35 +Shortest transaction: 0.14 +]]></example> + +</slide> diff --git a/slides/intro/wp1b.xml b/slides/intro/wp1b.xml new file mode 100644 index 0000000..aa39a51 --- /dev/null +++ b/slides/intro/wp1b.xml @@ -0,0 +1,27 @@ +<slide title="Wordpress"> + +<break lines="1" /> + +<link fontsize="3em" marginleft="1em" leader="Siege: " href="http://www.joedog.org/JoeDog/Siege"/> + +<example fontsize="1.4em" type="shell" title="Baseline Benchmark Wordpress-svn PHP-FPM-5.4.5-dev nginx-1.1.19"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp1.localhost/?p=1"* +** SIEGE 2.70 +** Preparing 5 concurrent users for battle. +The server is now under siege... +Lifting the server siege.. done. +Transactions: 659 hits +Availability: 100.00 % +Elapsed time: 29.02 secs +Data transferred: 5.32 MB +Response time: *0.22 secs* +Transaction rate: *22.71 trans/sec* +Throughput: 0.18 MB/sec +Concurrency: 4.97 +Successful transactions: 659 +Failed transactions: 0 +Longest transaction: 1.62 +Shortest transaction: 0.13 +]]></example> + +</slide> diff --git a/slides/intro/wp2.xml b/slides/intro/wp2.xml index 2c9a86a..7687751 100644 --- a/slides/intro/wp2.xml +++ b/slides/intro/wp2.xml @@ -4,26 +4,25 @@ <link fontsize="3em" marginleft="1em" leader="APC: " href="http://pecl.php.net/APC"/> -<example fontsize="1.4em" title="Set your default timezone in php.ini file"><![CDATA[date.timezone = "America/Los_Angeles"]]></example> - -<example fontsize="1.4em" type="shell" title="Benchmarking PHP-5.3.3-dev w/ APC-3.1.4-dev zend.enable_gc=Off"><![CDATA[ -|0077aa|~>| *siege -c 5 -b -t30s http://wp1.localhost* -** SIEGE 2.68 +<example fontsize="1.4em" type="shell" title="Benchmarking PHP-5.4.5-dev w/ APC-3.1.11-dev --enable-apc-pthreadrwlocks"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp1.localhost/?p=1"* +** SIEGE 2.70 ** Preparing 5 concurrent users for battle. The server is now under siege... -Lifting the server siege... done. -Transactions: 788 hits +Lifting the server siege.. done. +Transactions: 2259 hits Availability: 100.00 % -Elapsed time: 29.27 secs -Data transferred: 1.66 MB -Response time: *0.18 secs* -Transaction rate: *26.92 trans/sec* -Throughput: 0.06 MB/sec -Concurrency: 4.97 -Successful transactions: 788 +Elapsed time: 29.70 secs +Data transferred: 18.24 MB +Response time: *0.07 secs* +Transaction rate: *76.06 trans/sec* +Throughput: 0.61 MB/sec +Concurrency: 4.99 +Successful transactions: 2259 Failed transactions: 0 -Longest transaction: 0.65 -Shortest transaction: 0.07]]></example> +Longest transaction: 0.13 +Shortest transaction: 0.03 +]]></example> <example title="Make sure we are cpu-bound" fontsize="1.3em" type="shell"> |0077aa|~>| *vmstat 1* diff --git a/slides/intro/wp5.xml b/slides/intro/wp5.xml index cdd8978..1721f0c 100644 --- a/slides/intro/wp5.xml +++ b/slides/intro/wp5.xml @@ -4,125 +4,136 @@ <example fontsize="1.4em" type="shell" title="Check for open() syscalls"><![CDATA[ |0077aa|~>| *grep open strace.out* -open("/var/www/wp1/wp-load.php", O_RDONLY) = 29 -open("/var/www/wp1/wp-config.php", O_RDONLY) = 29 -open("/var/www/wp1/wp-settings.php", O_RDONLY) = 29 -open("/var/www/wp1/wp-includes/wp-db.php", O_RDONLY) = 29 -open("/var/www/wp1/wp-includes/cache.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/pomo/translations.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/pomo/entry.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/pomo/streams.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/default-widgets.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/default-embeds.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-includes/template-loader.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/header.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/sidebar.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/footer.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/style.css", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickbgcolor.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickbg-ltr.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickheader.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickfooter.jpg", O_RDONLY) = 29]]></example> +open("/var/www/wp1/wp-load.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-config.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-settings.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/pomo/translations.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/pomo/entry.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/pomo/streams.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/wp-db.php", O_RDONLY) = 27 +open("/var/www/wp1/wp-includes/cache.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-includes/l10n.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-includes/default-widgets.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-includes/locale.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-includes/template-loader.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-content/themes/twentyeleven/header.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-content/themes/twentyeleven/style.css", O_RDONLY) = 28 +open("/var/www/wp1/wp-content/themes/twentyeleven/footer.php", O_RDONLY) = 28 +open("/var/www/wp1/wp-content/themes/twentyeleven/sidebar-footer.php", O_RDONLY) = 28 +]]></example> <example fontsize="1em" title="Conditional config include in wp-load.php"><![CDATA[<?php if ( file_exists( ABSPATH . 'wp-config.php') ) { - /** The config file resides in ABSPATH */ - require_once( ABSPATH . 'wp-config.php' ); + + /** The config file resides in ABSPATH */ + require_once( ABSPATH . 'wp-config.php' ); } elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) && ! file_exists( dirname(ABSPATH) . '/wp-settings.php' ) ) { - /** The config file resides one level above ABSPATH but is not part of another install*/ - require_once( dirname(ABSPATH) . '/wp-config.php' ); + + /** The config file resides one level above ABSPATH but is not part of another install */ + require_once( dirname(ABSPATH) . '/wp-config.php' ); + } else { - // A config file doesn't exist - // Set a path for the link to the installer - if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; - else $path = 'wp-admin/'; - - // Die with an error message - require_once( ABSPATH . '/wp-includes/classes.php' ); - require_once( ABSPATH . '/wp-includes/functions.php' ); - require_once( ABSPATH . '/wp-includes/plugin.php' ); - $text_direction = /*WP_I18N_TEXT_DIRECTION*/"ltr"/*/WP_I18N_TEXT_DIRECTION*/; - wp_die(sprintf(/*WP_I18N_NO_CONFIG*/"There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can ge -t started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can create a <code>wp-config -.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file. -</p><p><a href='%ssetup-config.php' class='button'>Create a Configuration File</a>"/*/WP_I18N_NO_CONFIG*/, $path), /*WP_I18N_ERROR_TI -TLE*/"WordPress › Error"/*/WP_I18N_ERROR_TITLE*/, array('text_direction' => $text_direction)); -} -?>]]></example> + + // A config file doesn't exist + + // Set a path for the link to the installer + if ( strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false ) + $path = 'setup-config.php'; + else + $path = 'wp-admin/setup-config.php'; + + define( 'WPINC', 'wp-includes' ); + define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); + require_once( ABSPATH . WPINC . '/load.php' ); + require_once( ABSPATH . WPINC . '/version.php' ); + + wp_load_translations_early(); + wp_check_php_mysql_versions(); + + // Die with an error message + $die = __( "There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started." ) . '</p>'; + $die .= '<p>' . __( "Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>." ) . '</p>'; + $die .= '<p>' . __( "You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file." ) . '</p>'; + $die .= '<p><a href="' . $path . '" class="button">' . __( "Create a Configuration File" ) . '</a>'; + + wp_die( $die, __( 'WordPress › Error' ) ); +}]]></example> <example fontsize="1.4em" title="Replace with"><![CDATA[<?php -include './wp-config.php'; -?>]]></example> +include './wp-config.php';]]></example> + +<example fontsize="1.4em" title="Get rid of require_once of wp-settings.php in wp-config.php"><![CDATA[<?php +#require_once(ABSPATH . 'wp-settings.php'); +require './wp-settings.php';]]></example> + +<example fontsize="1.4em" title="Get rid of require_once calls in wp-settings.php"><![CDATA[<?php +#require_once( ABSPATH . WPINC . '/l10n.php' ) +require './wp-includes/l10n.php'; +... +require_once( ABSPATH . WPINC . '/locale.php' ); +require './wp-includes/locale.php';]]></example> <example fontsize="1.4em" title="Conditional did-header check in wp-blog-header.php"><![CDATA[<?php #if ( !isset($wp_did_header) ) { - $wp_did_header = true; - require_once( dirname(__FILE__) . '/wp-load.php' ); - wp(); - require_once( ABSPATH . WPINC . '/template-loader.php' ); +# $wp_did_header = true; +# require_once( dirname(__FILE__) . '/wp-load.php' ); +# wp(); +# require_once( ABSPATH . WPINC . '/template-loader.php' ); #} +require './wp-load.php'; +wp(); +require './wp-includes/template-loader.php'; ?>]]></example> -<example fontsize="1.4em" title="require_wp_db() call in wp-includes/functions.php"><![CDATA[<?php +<example fontsize="1.4em" title="require_wp_db() call in wp-includes/load.php"><![CDATA[<?php function require_wp_db() { - global $wpdb; - if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) - require_once( WP_CONTENT_DIR . '/db.php' ); - else - require_once( ABSPATH . WPINC . '/wp-db.php' ); -} -?>]]></example> + global $wpdb; + + require_once( ABSPATH . WPINC . '/wp-db.php' ); + if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) + require_once( WP_CONTENT_DIR . '/db.php' ); + + if ( isset( $wpdb ) ) + return; + + $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); +}]]></example> <example fontsize="1.4em" title="Don't call require_wp_db() from wp-settings.php"><![CDATA[<?php #require_wp_db(); require './wp-includes/wp-db.php'; +$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); ]]></example> <example fontsize="1.4em" title="Hardcode built-in wp cache in wp-settings.php"><![CDATA[<?php require './wp-includes/cache.php'; +$_wp_using_ext_object_cache = false; +wp_cache_init(); +wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) ); +wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); +#wp_start_object_cache(); ]]></example> -<example fontsize="1.4em" title="Remove conditional require logic from wp_start_object_cache"><![CDATA[<?php -function wp_start_object_cache() { - global $_wp_using_ext_object_cache; - $first_init = false; - $_wp_using_ext_object_cache = false; - static $first_init = true; - -# if ( ! function_exists( 'wp_cache_init' ) ) { -# global $_wp_using_ext_object_cache; -# if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { -# require_once ( WP_CONTENT_DIR . '/object-cache.php' ); -# $_wp_using_ext_object_cache = true; -# } else { -# require_once ( ABSPATH . WPINC . '/cache.php' ); -# $_wp_using_ext_object_cache = false; -# } -# $first_init = true; -# } -...]]></example> +<example fontsize="1.4em" title="PHP 5.3 has a __DIR__ constant - use in wp-load.php"><![CDATA[<?php +#define( 'ABSPATH', dirname(__FILE__) . '/' ); +define( 'ABSPATH', __DIR__ . '/' ); +]]></example> <example fontsize="1.4em" type="shell" title="Check again"><![CDATA[ |0077aa|~>| *grep open strace2.out* -open("/var/www/wp2/wp-includes/pomo/translations.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/pomo/entry.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/pomo/streams.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/default-widgets.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/default-embeds.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-includes/template-loader.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-content/themes/default/header.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-content/themes/default/sidebar.php", O_RDONLY) = 30 -open("/var/www/wp2/wp-content/themes/default/footer.php", O_RDONLY) = 30 -open("/var/www/wp1/wp-content/themes/default/style.css", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickbgcolor.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickbg-ltr.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickheader.jpg", O_RDONLY) = 29 -open("/var/www/wp1/wp-content/themes/default/images/kubrickfooter.jpg", O_RDONLY) = 29 +open("/var/www/wp2/wp-includes/pomo/translations.php", O_RDONLY) = 27 +open("/var/www/wp2/wp-includes/pomo/entry.php", O_RDONLY) = 27 +open("/var/www/wp2/wp-includes/pomo/streams.php", O_RDONLY) = 27 +open("/var/www/wp2/wp-includes/default-widgets.php", O_RDONLY) = 28 +open("/var/www/wp2/wp-content/themes/twentyeleven/header.php", O_RDONLY) = 28 +open("/var/www/wp2/wp-content/themes/twentyeleven/style.css", O_RDONLY) = 28 +open("/var/www/wp2/wp-content/themes/twentyeleven/footer.php", O_RDONLY) = 28 +open("/var/www/wp2/wp-content/themes/twentyeleven/sidebar-footer.php", O_RDONLY) = 28 ]]></example> <blurb fontsize="3em"> -We just have translations, plugins and themes left here now. We could hardcode these as +We just have translations, plugin widgets and themes left here now. We could hardcode these as well, but then we start to lose the main characteristics of Wordpress. </blurb> </slide> diff --git a/slides/intro/wp5a.xml b/slides/intro/wp5a.xml new file mode 100644 index 0000000..8c2102e --- /dev/null +++ b/slides/intro/wp5a.xml @@ -0,0 +1,25 @@ +<slide title="Benchmark again"> + +<break lines="1" /> + +<example fontsize="1.4em" type="shell" title="Benchmarking PHP-5.4.5-dev w/ APC-3.1.11-dev --enable-apc-pthreadrwlocks"><![CDATA[ +|0077aa|~>| *siege -c 5 -b -t30s "http://wp2.localhost/?p=1"* +** SIEGE 2.70 +** Preparing 5 concurrent users for battle. +The server is now under siege... +Lifting the server siege.. done. +Transactions: 2331 hits +Availability: 100.00 % +Elapsed time: 29.40 secs +Data transferred: 18.82 MB +Response time: *0.06 secs* +Transaction rate: *79.29 trans/sec* +Throughput: 0.64 MB/sec +Concurrency: 4.99 +Successful transactions: 2331 +Failed transactions: 0 +Longest transaction: 0.12 +Shortest transaction: 0.02 +]]></example> + +</slide> diff --git a/slides/intro/wp6.xml b/slides/intro/wp6.xml index 98be1c5..e796734 100644 --- a/slides/intro/wp6.xml +++ b/slides/intro/wp6.xml @@ -3,7 +3,8 @@ <break lines="1" /> <blurb fontsize="3.5em"> -Set *error_reporting(-1)* in *wp-settings.php* to catch all warnings +Set *error_reporting(-1)* in *wp-load.php* and *wp-includes/load.php* to catch all warnings. +Wordpress has fixed all of them in the current version. Previously we saw warnings like this: </blurb> <example fontsize="0.8em" type="shell" title=""><![CDATA[ diff --git a/slides/intro/wp6a.xml b/slides/intro/wp6a.xml new file mode 100644 index 0000000..9b62535 --- /dev/null +++ b/slides/intro/wp6a.xml @@ -0,0 +1,33 @@ +<slide title="Fix all warnings"> + +<break lines="1" /> + +<blurb fontsize="3em"> +Set *error_reporting(-1)* in *wp-load.php* and *wp-includes/load.php* to catch all warnings. +Wordpress has fixed most of them in the current version. +</blurb> + +<example fontsize="0.8em" type="shell" title=""><![CDATA[ + +Strict Standards: Redefining already defined constructor for class WP_Widget in /var/www/wp2/wp-includes/widgets.php on line 93 + +]]></example> + +<example fontsize="1.4em" title="Stray PHP4 constructor"><![CDATA[<?php +/** + * PHP4 constructor + */ +function WP_Widget( $id_base = false, $name, $widget_options = array(), $control_options = array() ) { + WP_Widget::__construct( $id_base, $name, $widget_options, $control_options ); +} +]]></example> + +<break lines="1"/> + +<example fontsize="0.8em" type="shell" title=""><![CDATA[ + +Fatal error: Call to undefined method Twenty_Eleven_Ephemera_Widget::WP_Widget() in /var/www/wp2/wp-content/themes/twentyeleven/inc/widgets.php on line 20 + +]]></example> + +</slide> diff --git a/slides/intro/wp8.xml b/slides/intro/wp8.xml index 28382ef..1aa5eac 100644 --- a/slides/intro/wp8.xml +++ b/slides/intro/wp8.xml @@ -11,6 +11,6 @@ xdebug.profiler_output_dir=/tmp]]></example> <example fontsize="2em" type="shell"><![CDATA[|0077aa|~>| *kcachegrind cachegrind.out.\**]]></example> -<image filename="wp_xdebug.png" width="1003" height="597" align="center"/> +<image filename="wp_xdebug.png" width="1022" height="596" align="center"/> </slide> diff --git a/slides/intro/wp9a.xml b/slides/intro/wp9a.xml new file mode 100644 index 0000000..21fe022 --- /dev/null +++ b/slides/intro/wp9a.xml @@ -0,0 +1,102 @@ +<slide title="Check xhprof"> + +<break lines="1" /> +<example fontsize="1.4em" type="shell" title="pecl/xhprof extension in php.ini"><![CDATA[extension=xhprof.so +xhprof.output_dir=/tmp]]></example> + +<example fontsize="1.4em" type="shell" title="xhprof vhost"><![CDATA[<VirtualHost *:80> + ServerName xhprof.localhost + UseCanonicalName Off + DocumentRoot /var/www/xhprof + ErrorLog /var/log/apache2/xhprof-error.log + CustomLog /var/log/apache2/xhprof-access.log combined + DirectoryIndex index.php index.html +</VirtualHost>]]></example> + +<example fontsize="1.4em" type="shell" title="enable xhprof for a vhost"><![CDATA[ +# For XHPROF Profiling + php_value auto_prepend_file /var/www/xhprof/header.php + php_value auto_append_file /var/www/xhprof/footer.php +...]]></example> + +<example fontsize="1.4em" title="header.php"><![CDATA[<?php +include '/var/www/xhprof/xhprof_lib/utils/xhprof_lib.php'; +include '/var/www/xhprof/xhprof_lib/utils/xhprof_runs.php'; +xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);]]></example> + +<example fontsize="1.4em" title="footer.php"><![CDATA[<?php +$app = $_SERVER['HTTP_HOST']; +$xhprof_data = xhprof_disable(); +$xhprof_runs = new XHProfRuns_Default(); +$id = $xhprof_runs->save_run($xhprof_data, $app); +$ua = urlencode($app); +$profiler_url = "http://xhprof.localhost/index.php?run=$id&source=$ua"; +echo '<a href="'. $profiler_url .'" target="_blank">Profiler output</a>';]]></example> + +<blurb fontsize="3.5em"> +Now hit the server a few times to warm up the caches, then click the "Profiler Output" link at the bottom. +</blurb> + +<example fontsize="1.25em" type="shell" title="mysql_connect and mysql_set_charset"><![CDATA[ +--- wp-db.php (revision 13595) ++++ wp-db.php (working copy) +@@ -499,7 +499,7 @@ +- $this->dbh = *@mysql_connect*( $dbhost, $dbuser, $dbpassword, *true* ); ++ $this->dbh = *mysql_pconnect*( $dbhost, $dbuser, $dbpassword ); +@@ -518,7 +516,7 @@ +- mysql_set_charset( $this->charset, $this->dbh ); ++# mysql_set_charset( $this->charset, $this->dbh ); +]]></example> + +<blurb fontsize="2.5em"> +And as we are browsing the source code, we can replace most *time()* calls with *$_SERVER['REQUEST_TIME']* and also any +*date()* or *gmdate()* calls that don't already have a timestamp argument, we can add *$_SERVER['REQUEST_TIME']* to those. +</blurb> + +<example fontsize="1em" type="shell" title="$_SERVER['REQUEST_TIME'] example"><![CDATA[--- ./load.php 2010-03-05 09:31:16.573829617 -0800 ++++ ../../wp2/wp-includes/load.php 2010-03-05 16:57:13.452580398 -0800 +@@ -138,7 +138,7 @@ +- if ( ( *time()* - $upgrading ) >= 600 ) ++ if ( ( *$_SERVER['REQUEST_TIME']* - $upgrading ) >= 600 ) +]]></example> + +<blurb fontsize="3.5em"> +And finally, let's disable the phone-home version update check and the cron functionality. +We can do these out-of-band ourselves. +</blurb> + +<example fontsize="1em" type="shell" title="Disable cron and update check"><![CDATA[... +Index: wp-settings.php +=================================================================== +--- wp-settings.php (revision 13594) ++++ wp-settings.php (working copy) +@@ -118,11 +117,11 @@ + require( ABSPATH . WPINC . '/bookmark.php' ); + require( ABSPATH . WPINC . '/bookmark-template.php' ); + require( ABSPATH . WPINC . '/kses.php' ); +-require( ABSPATH . WPINC . '/cron.php' ); ++*#*require( ABSPATH . WPINC . '/cron.php' ); + require( ABSPATH . WPINC . '/deprecated.php' ); + require( ABSPATH . WPINC . '/script-loader.php' ); + require( ABSPATH . WPINC . '/taxonomy.php' ); +-require( ABSPATH . WPINC . '/update.php' ); ++*#*require( ABSPATH . WPINC . '/update.php' ); + require( ABSPATH . WPINC . '/canonical.php' ); + require( ABSPATH . WPINC . '/shortcodes.php' ); + require( ABSPATH . WPINC . '/media.php' ); + +Index: default-filters.php +=================================================================== +--- default-filters.php (revision 13595) ++++ default-filters.php (working copy) +@@ -198,8 +198,8 @@ + } + + // WP Cron +-if ( !defined( 'DOING_CRON' ) ) +- add_action( 'sanitize_comment_cookies', 'wp_cron' ); ++*#*if ( !defined( 'DOING_CRON' ) ) ++*#* add_action( 'sanitize_comment_cookies', 'wp_cron' ); +]]></example> + +</slide> diff --git a/slides/intro/wp_xdebug.png b/slides/intro/wp_xdebug.png index b4789da..ec35283 100644 Binary files a/slides/intro/wp_xdebug.png and b/slides/intro/wp_xdebug.png differ