Page MenuHomePhabricator

count "real" htmlCacheUpdate jobs

Authored By
EBernhardson
Aug 24 2017, 11:20 PM
Size
1 KB
Referenced Files
None
Subscribers
None

count "real" htmlCacheUpdate jobs

<?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 += countRealJobs($job);
$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;
}

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4876143
Default Alt Text
count "real" htmlCacheUpdate jobs (1 KB)

Event Timeline