@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move GC into PHP and simplify it

Summary:
- Move GC options into PHP.
- Remove the "run at" and "run for" options. The GC daemon doesn't actually do any table scans, is very gentle, and runs for like 3 seconds per day in any normal install. Just limit it to running once every 4 hours when it's caught up and call it a day.

Test Plan: Edited GC options.

Reviewers: btrahan, codeblock

Reviewed By: codeblock

CC: aran

Maniphest Tasks: T2255

Differential Revision: https://secure.phabricator.com/D4321

+56 -50
-14
conf/default.conf.php
··· 1144 1144 // manageable. To run garbage collection, launch a 1145 1145 // PhabricatorGarbageCollector daemon. 1146 1146 1147 - // Since the GC daemon can issue large writes and table scans, you may want to 1148 - // run it only during off hours or make sure it is scheduled so it doesn't 1149 - // overlap with backups. This determines when the daemon can start running 1150 - // each day. 1151 - 'gcdaemon.run-at' => '12 AM', 1152 - 1153 - // How many seconds after 'gcdaemon.run-at' the daemon may collect garbage 1154 - // for. By default it runs continuously, but you can set it to run for a 1155 - // limited period of time. For instance, if you do backups at 3 AM, you might 1156 - // run garbage collection for an hour beforehand. This is not a high-precision 1157 - // limit so you may want to leave some room for the GC to actually stop, and 1158 - // if you set it to something like 3 seconds you're on your own. 1159 - 'gcdaemon.run-for' => 24 * 60 * 60, 1160 - 1161 1147 // These 'ttl' keys configure how much old data the GC daemon keeps around. 1162 1148 // Objects older than the ttl will be collected. Set any value to 0 to store 1163 1149 // data indefinitely.
+2
src/__phutil_library_map__.php
··· 843 843 'PhabricatorFlagQuery' => 'applications/flag/query/PhabricatorFlagQuery.php', 844 844 'PhabricatorFlagsUIEventListener' => 'applications/flag/events/PhabricatorFlagsUIEventListener.php', 845 845 'PhabricatorFormExample' => 'applications/uiexample/examples/PhabricatorFormExample.php', 846 + 'PhabricatorGarbageCollectorConfigOptions' => 'applications/config/option/PhabricatorGarbageCollectorConfigOptions.php', 846 847 'PhabricatorGarbageCollectorDaemon' => 'infrastructure/daemon/PhabricatorGarbageCollectorDaemon.php', 847 848 'PhabricatorGitGraphStream' => 'applications/repository/daemon/PhabricatorGitGraphStream.php', 848 849 'PhabricatorGitHubConfigOptions' => 'applications/config/option/PhabricatorGitHubConfigOptions.php', ··· 2180 2181 'PhabricatorFlagListView' => 'AphrontView', 2181 2182 'PhabricatorFlagsUIEventListener' => 'PhutilEventListener', 2182 2183 'PhabricatorFormExample' => 'PhabricatorUIExample', 2184 + 'PhabricatorGarbageCollectorConfigOptions' => 'PhabricatorApplicationConfigOptions', 2183 2185 'PhabricatorGarbageCollectorDaemon' => 'PhabricatorDaemon', 2184 2186 'PhabricatorGitHubConfigOptions' => 'PhabricatorApplicationConfigOptions', 2185 2187 'PhabricatorGlobalLock' => 'PhutilLock',
+52
src/applications/config/option/PhabricatorGarbageCollectorConfigOptions.php
··· 1 + <?php 2 + 3 + final class PhabricatorGarbageCollectorConfigOptions 4 + extends PhabricatorApplicationConfigOptions { 5 + 6 + public function getName() { 7 + return pht("Garbage Collector"); 8 + } 9 + 10 + public function getDescription() { 11 + return pht("Configure the GC for old logs, caches, etc."); 12 + } 13 + 14 + public function getOptions() { 15 + 16 + $options = array( 17 + 'gcdaemon.ttl.herald-transcripts' => array( 18 + 30, 19 + pht('Number of seconds to retain Herald transcripts for.')), 20 + 'gcdaemon.ttl.daemon-logs' => array( 21 + 14, 22 + pht('Number of seconds to retain Daemon logs for.')), 23 + 'gcdaemon.ttl.differential-parse-cache' => array( 24 + 14, 25 + pht('Number of seconds to retain Differential parse caches for.')), 26 + 'gcdaemon.ttl.markup-cache' => array( 27 + 30, 28 + pht('Number of seconds to retain Markup cache entries for.')), 29 + 'gcdaemon.ttl.task-archive' => array( 30 + 14, 31 + pht('Number of seconds to retain archived background tasks for.')), 32 + 'gcdaemon.ttl.general-cache' => array( 33 + 30, 34 + pht('Number of seconds to retain general cache entries for.')), 35 + ); 36 + 37 + $result = array(); 38 + foreach ($options as $key => $spec) { 39 + list($default_days, $description) = $spec; 40 + $result[] = $this 41 + ->newOption($key, 'int', $default_days * (24 * 60 * 60)) 42 + ->setDescription($description) 43 + ->addExample((7 * 24 * 60 * 60), pht('Retain for 1 week')) 44 + ->addExample((14 * 24 * 60 * 60), pht('Retain for 2 weeks')) 45 + ->addExample((30 * 24 * 60 * 60), pht('Retain for 30 days')) 46 + ->addExample((60 * 24 * 60 * 60), pht('Retain for 60 days')) 47 + ->addExample(0, pht('Retain indefinitely')); 48 + } 49 + return $result; 50 + } 51 + 52 + }
+2 -36
src/infrastructure/daemon/PhabricatorGarbageCollectorDaemon.php
··· 9 9 final class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon { 10 10 11 11 public function run() { 12 - 13 - // Keep track of when we start and stop the GC so we can emit useful log 14 - // messages. 15 - $just_ran = false; 16 - 17 12 do { 18 - $run_at = PhabricatorEnv::getEnvConfig('gcdaemon.run-at'); 19 - $run_for = PhabricatorEnv::getEnvConfig('gcdaemon.run-for'); 20 - 21 - // Just use the default timezone, we don't need to get fancy and try 22 - // to localize this. 23 - $start = strtotime($run_at); 24 - if ($start === false) { 25 - throw new Exception( 26 - "Configuration 'gcdaemon.run-at' could not be parsed: '{$run_at}'."); 27 - } 28 - 29 - $now = time(); 30 - 31 - if ($now < $start || $now > ($start + $run_for)) { 32 - if ($just_ran) { 33 - $this->log("Stopped garbage collector."); 34 - $just_ran = false; 35 - } 36 - // The configuration says we can't collect garbage right now, so 37 - // just sleep until we can. 38 - $this->sleep(300); 39 - continue; 40 - } 41 - 42 - if (!$just_ran) { 43 - $this->log("Started garbage collector."); 44 - $just_ran = true; 45 - } 46 - 47 13 $n_herald = $this->collectHeraldTranscripts(); 48 14 $n_daemon = $this->collectDaemonLogs(); 49 15 $n_parse = $this->collectParseCaches(); ··· 70 36 if ($total < 100) { 71 37 // We didn't max out any of the GCs so we're basically caught up. Ease 72 38 // off the GC loop so we don't keep doing table scans just to delete 73 - // a handful of rows. 74 - $this->sleep(300); 39 + // a handful of rows; wake up in a few hours. 40 + $this->sleep(4 * (60 * 60)); 75 41 } else { 76 42 $this->stillWorking(); 77 43 }