From 205657ac76a210553acd6f60821e7ab945577d5e Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 1 Jul 2020 04:03:53 -0700 Subject: [PATCH] Allow the Fact daemon to hibernate Summary: A handful of Phacility production shards have run into memory pressure issues recently. Although there's no smoking gun, and at least two other plausible contributors, one possible concern is that the Fact daemon was written before hibernation and can not currently hibernate. Even if there's no memory leak, this creates unnecessary memory pressure by holding the processes in memory. Allow the Fact daemon to hibernate, like other daemons do. Test Plan: Ran "bin/phd debug fact", saw the Fact daemon hibernate. Subscribers: yelirekim Differential Revision: https://secure.phabricator.com/D21389 --- .../fact/daemon/PhabricatorFactDaemon.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/applications/fact/daemon/PhabricatorFactDaemon.php b/src/applications/fact/daemon/PhabricatorFactDaemon.php index 29c7904547..4b4f7da368 100644 --- a/src/applications/fact/daemon/PhabricatorFactDaemon.php +++ b/src/applications/fact/daemon/PhabricatorFactDaemon.php @@ -6,7 +6,7 @@ final class PhabricatorFactDaemon extends PhabricatorDaemon { protected function run() { $this->setEngines(PhabricatorFactEngine::loadAllEngines()); - while (!$this->shouldExit()) { + do { PhabricatorCaches::destroyRequestCache(); $iterators = $this->getAllApplicationIterators(); @@ -14,9 +14,14 @@ final class PhabricatorFactDaemon extends PhabricatorDaemon { $this->processIteratorWithCursor($iterator_name, $iterator); } - $this->log(pht('Zzz...')); - $this->sleep(15); - } + $sleep_duration = 60; + + if ($this->shouldHibernate($sleep_duration)) { + break; + } + + $this->sleep($sleep_duration); + } while (!$this->shouldExit()); } public static function getAllApplicationIterators() {