Skip to content

Commit

Permalink
Merge pull request #159 from jpwhite4/shared_perf
Browse files Browse the repository at this point in the history
Performance Improvements for shared_jobs script
  • Loading branch information
jpwhite4 authored Mar 29, 2019
2 parents fd3ef5b + 488bac4 commit 70098c8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions background_scripts/supremm_sharedjobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,26 @@ function shared_jobs($resource_id, $start, $end)
$jbu->execute(array($key));
}
$logger->debug("Processed " . count($sharedjobs) . " jobs for host " . $host['name']);

if ($jobpeercount > 250000) {
fclose($jobpeersfile);
batch_update($jobpeersfname, $jobpeercount);
$jobpeersfile = fopen($jobpeersfname, 'wb');
$jobpeercount = 0;
}
}

fclose($jobpeersfile);
batch_update($jobpeersfname, $jobpeercount);

unlink($jobpeersfname);
$db->handle()->exec('DROP TABLE IF EXISTS `modw_supremm`.`job_tmp`');
}

function batch_update($jobpeersfname, $jobpeercount)
{
global $logger;
global $db;

if ($jobpeercount > 0) {
$logger->info('Batch update ' . $jobpeercount . ' job peers');
Expand All @@ -222,9 +239,6 @@ function shared_jobs($resource_id, $start, $end)
} else {
$logger->info('Skipping batch update - no job peers found');
}

unlink($jobpeersfname);
$db->handle()->exec('DROP TABLE IF EXISTS `modw_supremm`.`job_tmp`');
}

/**
Expand Down

0 comments on commit 70098c8

Please sign in to comment.