Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'master' into jtr/fix-cron-memory-usage-levels
Signed-off-by: Josh <[email protected]>
  • Loading branch information
joshtrichards authored Jun 12, 2024
commit ecef3922317cc28e6d34c609e266b68159c2146e
17 changes: 17 additions & 0 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@
$memoryAfter = memory_get_usage();
$memoryPeakAfter = memory_get_peak_usage();

$cronInterval = 5 * 60;
$timeSpent = $timeAfter - $timeBefore;
if ($timeSpent > $cronInterval) {
$logLevel = match (true) {
$timeSpent > $cronInterval * 128 => \OCP\ILogger::FATAL,
$timeSpent > $cronInterval * 64 => \OCP\ILogger::ERROR,
$timeSpent > $cronInterval * 16 => \OCP\ILogger::WARN,
$timeSpent > $cronInterval * 8 => \OCP\ILogger::INFO,
default => \OCP\ILogger::DEBUG,
};
$logger->log(
$logLevel,
'Background job ' . $jobDetails . ' ran for ' . $timeSpent . ' seconds',
['app' => 'cron']
);
}

if ($memoryAfter - $memoryBefore > 50_000_000) {
$logger->warning('Used memory grew by more than 50 MB when executing job ' . $jobDetails . ': ' . Util::humanFileSize($memoryAfter). ' (before: ' . Util::humanFileSize($memoryBefore) . ')', ['app' => 'cron']);
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.