1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +01:00

Add Differential parse cache to the GC daemon

Summary:
Add the differential parse cache to the GC. This is the largest object in the
system by a wide margin, I think.

This table is potentially gigantic which is why the script truncates it before
doing a schema change.

Test Plan: Ran the GC daemon, it cleaned up some parse caches.
Reviewed By: jungejason
Reviewers: tuomaspelkonen, jungejason, aran
Commenters: tuomaspelkonen
CC: aran, jungejason, tuomaspelkonen, epriestley
Differential Revision: 620
This commit is contained in:
epriestley 2011-07-08 15:26:33 -07:00
parent b8e7e06819
commit 51c2726a34
6 changed files with 36 additions and 11 deletions

View file

@ -413,7 +413,7 @@ return array(
'gcdaemon.ttl.herald-transcripts' => 30 * (24 * 60 * 60),
'gcdaemon.ttl.daemon-logs' => 7 * (24 * 60 * 60),
'gcdaemon.ttl.differential-render-cache' => 7 * (24 * 60 * 60),
'gcdaemon.ttl.differential-parse-cache' => 14 * (24 * 60 * 60),
// -- Customization --------------------------------------------------------- //

View file

@ -0,0 +1,7 @@
TRUNCATE phabricator_differential.differential_changeset_parse_cache;
ALTER TABLE phabricator_differential.differential_changeset_parse_cache
ADD dateCreated INT UNSIGNED NOT NULL;
ALTER TABLE phabricator_differential.differential_changeset_parse_cache
ADD KEY (dateCreated);

View file

@ -624,11 +624,12 @@ class DifferentialChangesetParser {
$conn_w = $changeset->establishConnection('w');
queryfx(
$conn_w,
'INSERT INTO %T (id, cache) VALUES (%d, %s)
'INSERT INTO %T (id, cache, dateCreated) VALUES (%d, %s, %d)
ON DUPLICATE KEY UPDATE cache = VALUES(cache)',
$changeset->getTableName().'_parse_cache',
DifferentialChangeset::TABLE_CACHE,
$render_cache_key,
$cache);
$cache,
time());
} catch (AphrontQueryException $ex) {
// TODO: uhoh
}

View file

@ -33,6 +33,8 @@ class DifferentialChangeset extends DifferentialDAO {
private $unsavedHunks = array();
private $hunks;
const TABLE_CACHE = 'differential_changeset_parse_cache';
protected function getConfiguration() {
return array(
self::CONFIG_SERIALIZATION => array(

View file

@ -62,12 +62,12 @@ class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon {
$n_herald = $this->collectHeraldTranscripts();
$n_daemon = $this->collectDaemonLogs();
$n_render = $this->collectRenderCaches();
$n_parse = $this->collectParseCaches();
$collected = array(
'Herald Transcript' => $n_herald,
'Daemon Log' => $n_daemon,
'Render Cache' => $n_render,
'Herald Transcript' => $n_herald,
'Daemon Log' => $n_daemon,
'Differential Parse Cache' => $n_parse,
);
$collected = array_filter($collected);
@ -131,9 +131,23 @@ class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon {
return $conn_w->getAffectedRows();
}
private function collectRenderCaches() {
// TODO: Implement this, no epoch column on the table right now.
return 0;
private function collectParseCaches() {
$key = 'gcdaemon.ttl.differential-parse-cache';
$ttl = PhabricatorEnv::getEnvConfig($key);
if ($ttl <= 0) {
return 0;
}
$table = new DifferentialChangeset();
$conn_w = $table->establishConnection('w');
queryfx(
$conn_w,
'DELETE FROM %T WHERE dateCreated < %d LIMIT 100',
DifferentialChangeset::TABLE_CACHE,
time() - $ttl);
return $conn_w->getAffectedRows();
}
}

View file

@ -6,6 +6,7 @@
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
phutil_require_module('phabricator', 'applications/herald/storage/transcript/base');
phutil_require_module('phabricator', 'infrastructure/daemon/base');
phutil_require_module('phabricator', 'infrastructure/daemon/storage/event');