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:
@@ -413,7 +413,7 @@ return array(
|
|||||||
|
|
||||||
'gcdaemon.ttl.herald-transcripts' => 30 * (24 * 60 * 60),
|
'gcdaemon.ttl.herald-transcripts' => 30 * (24 * 60 * 60),
|
||||||
'gcdaemon.ttl.daemon-logs' => 7 * (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 --------------------------------------------------------- //
|
// -- Customization --------------------------------------------------------- //
|
||||||
|
|||||||
7
resources/sql/patches/057.parsecache.sql
Normal file
7
resources/sql/patches/057.parsecache.sql
Normal 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);
|
||||||
@@ -624,11 +624,12 @@ class DifferentialChangesetParser {
|
|||||||
$conn_w = $changeset->establishConnection('w');
|
$conn_w = $changeset->establishConnection('w');
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn_w,
|
$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)',
|
ON DUPLICATE KEY UPDATE cache = VALUES(cache)',
|
||||||
$changeset->getTableName().'_parse_cache',
|
DifferentialChangeset::TABLE_CACHE,
|
||||||
$render_cache_key,
|
$render_cache_key,
|
||||||
$cache);
|
$cache,
|
||||||
|
time());
|
||||||
} catch (AphrontQueryException $ex) {
|
} catch (AphrontQueryException $ex) {
|
||||||
// TODO: uhoh
|
// TODO: uhoh
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ class DifferentialChangeset extends DifferentialDAO {
|
|||||||
private $unsavedHunks = array();
|
private $unsavedHunks = array();
|
||||||
private $hunks;
|
private $hunks;
|
||||||
|
|
||||||
|
const TABLE_CACHE = 'differential_changeset_parse_cache';
|
||||||
|
|
||||||
protected function getConfiguration() {
|
protected function getConfiguration() {
|
||||||
return array(
|
return array(
|
||||||
self::CONFIG_SERIALIZATION => array(
|
self::CONFIG_SERIALIZATION => array(
|
||||||
|
|||||||
@@ -62,12 +62,12 @@ class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon {
|
|||||||
|
|
||||||
$n_herald = $this->collectHeraldTranscripts();
|
$n_herald = $this->collectHeraldTranscripts();
|
||||||
$n_daemon = $this->collectDaemonLogs();
|
$n_daemon = $this->collectDaemonLogs();
|
||||||
$n_render = $this->collectRenderCaches();
|
$n_parse = $this->collectParseCaches();
|
||||||
|
|
||||||
$collected = array(
|
$collected = array(
|
||||||
'Herald Transcript' => $n_herald,
|
'Herald Transcript' => $n_herald,
|
||||||
'Daemon Log' => $n_daemon,
|
'Daemon Log' => $n_daemon,
|
||||||
'Render Cache' => $n_render,
|
'Differential Parse Cache' => $n_parse,
|
||||||
);
|
);
|
||||||
$collected = array_filter($collected);
|
$collected = array_filter($collected);
|
||||||
|
|
||||||
@@ -131,9 +131,23 @@ class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon {
|
|||||||
return $conn_w->getAffectedRows();
|
return $conn_w->getAffectedRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function collectRenderCaches() {
|
private function collectParseCaches() {
|
||||||
// TODO: Implement this, no epoch column on the table right now.
|
$key = 'gcdaemon.ttl.differential-parse-cache';
|
||||||
|
$ttl = PhabricatorEnv::getEnvConfig($key);
|
||||||
|
if ($ttl <= 0) {
|
||||||
return 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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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', 'applications/herald/storage/transcript/base');
|
||||||
phutil_require_module('phabricator', 'infrastructure/daemon/base');
|
phutil_require_module('phabricator', 'infrastructure/daemon/base');
|
||||||
phutil_require_module('phabricator', 'infrastructure/daemon/storage/event');
|
phutil_require_module('phabricator', 'infrastructure/daemon/storage/event');
|
||||||
|
|||||||
Reference in New Issue
Block a user