Page MenuHomePhabricator
Paste P5916

count "real" htmlCacheUpdate jobs
ActivePublic

Authored by EBernhardson on Aug 24 2017, 7:28 PM.
<?php
$it = JobQueueGroup::singleton()->get( 'htmlCacheUpdate' )->getAllQueuedJobs();
$pending = 0;
$baseJobs = 0;
$emptyJobs = 0;
foreach ( $it as $job ) {
$new = countRealJobs($job);
if ($new === 0) {
$emptyJobs++;
} else {
$pending += $new;
$baseJobs++;
}
if (($baseJobs + $emptyJobs) % 1000 === 0) {
$ratio = $pending / $baseJobs;
echo "Empty: $emptyJobs Jobs: $baseJobs Real: $pending Per real job: $ratio\n";
flush();
if ($baseJobs + $emptyJobs >= 50000) {
break;
}
}
}
$ratio = $pending / $baseJobs;
echo "Empty: $emptyJobs Jobs: $baseJobs Real: $pending Per real job: $ratio\n";
function countRealJobs($job) {
global $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery;
$queue = [$job];
$pending = 0;
$i = 0;
while ($queue) {
if (++$i % 100 == 0) {
echo "queue: ", $queue, " handled: $i\n";
flush();
}
$job = array_pop($queue);
$params = $job->getParams();
if (isset($params['table']) &&!isset($params['pages'])) {
$params['recursive'] = true;
}
if (!empty($params['recursive'])) {
$jobs = BacklinkJobUtils::partitionBacklinkJob($job, $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery, []);
foreach ($jobs as $child) {
$queue[] = $child;
}
} else {
$pending += $job->workItemCount();
}
}
return $pending;
}