Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299421
Change subject: PHP is now the default cache format ...................................................................... PHP is now the default cache format Compared to serialised format, PHP files can be opcached: gain a factor 3. Mean time to load LocalSettings.php was previously 0.75ms with OPcache, it is now 0.33ms. Mean time to load LocalSettings.php without MediaWikiFarm is 0.19ms. Hence MediaWikiFarm takes 0.14ms (with OPcache). --- M docs/performance.rst M src/MediaWikiFarm.php 2 files changed, 21 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/21/299421/1 diff --git a/docs/performance.rst b/docs/performance.rst index ab8d077..cca3653 100644 --- a/docs/performance.rst +++ b/docs/performance.rst @@ -50,6 +50,10 @@ mean = 0.7494 median = 0.6160 std = 0.2886 min = 0.4861 max = 1.6530 range = 1.1668 values = 50 +* LocalSettings.php with only MediaWikiFarm extension with cache, with PHP extension OPcache and cache in PHP format: + + mean = 0.3264 median = 0.2786 std = 0.1485 min = 0.1972 max = 0.8500 range = 0.6528 values = 50 + Performance architecture ======================== diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index afaf74a..db5041b 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -576,8 +576,8 @@ $myWiki = $this->params['wikiID']; $mySuffix = $this->params['suffix']; - if( $this->params['version'] ) $cacheFile = $this->replaceVariables( 'config-$VERSION-$SUFFIX-$WIKIID.ser' ); - else $cacheFile = $this->replaceVariables( 'config-$SUFFIX-$WIKIID.ser' ); + if( $this->params['version'] ) $cacheFile = $this->replaceVariables( 'config-$VERSION-$SUFFIX-$WIKIID.php' ); + else $cacheFile = $this->replaceVariables( 'config-$SUFFIX-$WIKIID.php' ); $this->params['globals'] = false; # Check modification time of original config files @@ -828,8 +828,13 @@ if( !is_file( $prefixedFile ) ) return false; + # Format PHP + if( $format == '.php' ) + + $array = @include $prefixedFile; + # Format 'serialisation' - if( $format == '.ser' ) { + elseif( $format == '.ser' ) { $content = file_get_contents( $prefixedFile ); @@ -839,22 +844,17 @@ $array = @unserialize( $content ); } - # Format PHP - elseif( $format == '.php' ) - - $array = @include $prefixedFile; - # Cached version - elseif( is_string( $this->cacheDir ) && is_file( $this->cacheDir . '/' . $filename . '.ser' ) && @filemtime( $this->cacheDir . '/' . $filename . '.ser' ) >= filemtime( $prefixedFile ) ) + elseif( is_string( $this->cacheDir ) && is_file( $this->cacheDir . '/' . $filename . '.php' ) && @filemtime( $this->cacheDir . '/' . $filename . '.php' ) >= filemtime( $prefixedFile ) ) - return $this->readFile( $filename . '.ser', $this->cacheDir ); + return $this->readFile( $filename . '.php', $this->cacheDir ); # Format YAML elseif( $format == '.yml' || $format == '.yaml' ) { # Load Composer libraries # There is no warning if not present because to properly handle the error by returning false - # This is only included here to avoid delays (~3ms) during the loading using cached files or other formats + # This is only included here to avoid delays (~3ms without OPcache) during the loading using cached files or other formats if( is_file( dirname( __FILE__ ) . '/../vendor/autoload.php' ) ) include_once dirname( __FILE__ ) . '/../vendor/autoload.php'; @@ -897,7 +897,7 @@ if( is_array( $array ) ) { if( $format != '.php' && $format != '.ser' ) - $this->cacheFile( $array, $filename.'.ser' ); + $this->cacheFile( $array, $filename.'.php' ); return $array; } @@ -925,14 +925,14 @@ mkdir( dirname( $prefixedFile ) ); $tmpFile = $prefixedFile . '.tmp'; - if( preg_match( '/\.ser$/', $filename ) ) { + if( preg_match( '/\.php$/', $filename ) ) { + if( file_put_contents( $tmpFile, "<?php\n\n// WARNING: file automatically generated: do not modify.\n\nreturn ".var_export( $array, true ).';' ) ) + rename( $tmpFile, $prefixedFile ); + } + elseif( preg_match( '/\.ser$/', $filename ) ) { if( file_put_contents( $tmpFile, serialize( $array ) ) ) { rename( $tmpFile, $prefixedFile ); } - } - elseif( preg_match( '/\.php$/', $filename ) ) { - if( file_put_contents( $tmpFile, "<?php\n\n// WARNING: file automatically generated: do not modify.\n\nreturn ".var_export( $array, true ).';' ) ) - rename( $tmpFile, $prefixedFile ); } } -- To view, visit https://gerrit.wikimedia.org/r/299421 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie2201b91df2cbf4864099a866f00ce165efab01f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MediaWikiFarm Gerrit-Branch: master Gerrit-Owner: Seb35 <seb35wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits