Page MenuHomePhabricator
Paste P10713

l10n-php opcache stats (T99740)
ActivePublic

Authored by Krinkle on Tue, Mar 17, 9:17 PM.
<?php
define( 'MW_NO_SESSION', 1 );
require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
require MWMultiVersion::getMediaWiki( 'includes/WebStart.php' );
header( 'Content-Type: text/plain; charset=utf-8' );
function kfFmtBytes($num) {
if ($num < 1024) {
return $num . 'B';
}
$num /= 1024;
if ($num < 1024) {
return round($num) . 'KB';
}
$num /= 1024;
return round($num) . 'MB';
}
function kfDumpStuff(string $section) {
$oc = opcache_get_status();
$ac = apcu_sma_info();
$out = '
Opcache is enabled: '.(int)$oc['opcache_enabled'].'
Opcache is full: '.(int)$oc['cache_full'].'
Opcache memory used: '.kfFmtBytes($oc['memory_usage']['used_memory']).' / Opcache memory free: '.kfFmtBytes($oc['memory_usage']['free_memory']).'
Opcache strings mem used: '.kfFmtBytes($oc['interned_strings_usage']['used_memory']).' / Opcache strings mem free: '.kfFmtBytes($oc['interned_strings_usage']['free_memory']).'
';
echo "\n### $section\n";
echo trim($out) . "\n\n";
}
kfDumpStuff('Initial');
$files = array_merge(
glob("/srv/mediawiki/php-1.35.0-wmf.22/cache/l10n/*.php"),
glob("/srv/mediawiki/php-1.35.0-wmf.23/cache/l10n/*.php")
);
if (!$files)
die('No files found.');
echo 'Found ' . count($files) . " files.\n";
$chunks = array_chunk($files, 10);
echo 'Created ' . count($chunks) . " chunks of 10 files each.\n\n";
foreach (
$chunks
as
$i => $chunk
) {
#echo "Loading:\n";
foreach ($chunk as $file) {
#echo " * $file\n";
opcache_compile_file($file) or die("Failed to compile: $file");
}
kfDumpStuff('After chunk #' . $i);
if ( $i > 10 ) {
break;
}
}

Event Timeline

Krinkle created this paste.Tue, Mar 17, 9:17 PM
Krinkle edited the content of this paste. (Show Details)
Krinkle edited the content of this paste. (Show Details)Tue, Mar 17, 9:28 PM
Krinkle edited the content of this paste. (Show Details)Tue, Mar 17, 10:15 PM
Krinkle edited the content of this paste. (Show Details)
Krinkle edited the content of this paste. (Show Details)Tue, Mar 17, 10:20 PM