1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Provide more information about cache sizing in cache diagnostics

Summary: Ref T5501. This expands cache information a little more.

Test Plan: {F362975}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5501

Differential Revision: https://secure.phabricator.com/D12316
This commit is contained in:
epriestley 2015-04-07 15:08:47 -07:00
parent 0880788bd4
commit c5d38c6e08
5 changed files with 89 additions and 2 deletions

View file

@ -7,6 +7,10 @@ abstract class PhabricatorCacheSpec extends Phobject {
private $version; private $version;
private $issues = array(); private $issues = array();
private $usedMemory = 0;
private $totalMemory = 0;
private $entryCount = null;
public function setName($name) { public function setName($name) {
$this->name = $name; $this->name = $name;
return $this; return $this;
@ -50,4 +54,33 @@ abstract class PhabricatorCacheSpec extends Phobject {
return $this->issues; return $this->issues;
} }
public function setUsedMemory($used_memory) {
$this->usedMemory = $used_memory;
return $this;
}
public function getUsedMemory() {
return $this->usedMemory;
}
public function setTotalMemory($total_memory) {
$this->totalMemory = $total_memory;
return $this;
}
public function getTotalMemory() {
return $this->totalMemory;
}
public function setEntryCount($entry_count) {
$this->entryCount = $entry_count;
return $this;
}
public function getEntryCount() {
return $this->entryCount;
}
} }

View file

@ -21,6 +21,7 @@ final class PhabricatorDataCacheSpec extends PhabricatorCacheSpec {
if (ini_get('apc.enabled')) { if (ini_get('apc.enabled')) {
$spec->setIsEnabled(true); $spec->setIsEnabled(true);
self::getAPCCommonSpec($spec);
} else { } else {
$spec->setIsEnabled(false); $spec->setIsEnabled(false);
$spec->newIssue( $spec->newIssue(
@ -41,6 +42,7 @@ final class PhabricatorDataCacheSpec extends PhabricatorCacheSpec {
if (ini_get('apc.enabled')) { if (ini_get('apc.enabled')) {
$spec->setIsEnabled(true); $spec->setIsEnabled(true);
self::getAPCCommonSpec($spec);
} else { } else {
$spec->setIsEnabled(false); $spec->setIsEnabled(false);
$spec->newissue( $spec->newissue(
@ -70,4 +72,13 @@ final class PhabricatorDataCacheSpec extends PhabricatorCacheSpec {
return $spec; return $spec;
} }
private static function getAPCCommonSpec(PhabricatorDataCacheSpec $spec) {
$mem = apc_sma_info();
$spec->setTotalMemory($mem['num_seg'] * $mem['seg_size']);
$info = apc_cache_info('user');
$spec->setUsedMemory($info['mem_size']);
$spec->setEntryCount(count($info['cache_list']));
}
} }

View file

@ -21,6 +21,12 @@ final class PhabricatorOpcodeCacheSpec extends PhabricatorCacheSpec {
if (ini_get('apc.enabled')) { if (ini_get('apc.enabled')) {
$spec->setIsEnabled(true); $spec->setIsEnabled(true);
$mem = apc_sma_info();
$spec->setTotalMemory($mem['num_seg'] * $mem['seg_size']);
$info = apc_cache_info();
$spec->setUsedMemory($info['mem_size']);
} else { } else {
$spec->setIsEnabled(false); $spec->setIsEnabled(false);
$spec->newIssue( $spec->newIssue(
@ -41,6 +47,16 @@ final class PhabricatorOpcodeCacheSpec extends PhabricatorCacheSpec {
if (ini_get('opcache.enable')) { if (ini_get('opcache.enable')) {
$spec->setIsEnabled(true); $spec->setIsEnabled(true);
$status = opcache_get_status();
$memory = $status['memory_usage'];
$mem_used = $memory['used_memory'];
$mem_free = $memory['free_memory'];
$mem_junk = $memory['wasted_memory'];
$spec->setUsedMemory($mem_used + $mem_junk);
$spec->setTotalMemory($mem_used + $mem_junk + $mem_free);
$spec->setEntryCount($status['opcache_statistics']['num_cached_keys']);
} else { } else {
$spec->setIsEnabled(false); $spec->setIsEnabled(false);
$spec->newissue( $spec->newissue(

View file

@ -40,10 +40,11 @@ final class PhabricatorAPCSetupCheck extends PhabricatorSetupCheck {
} }
$is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode'); $is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
$is_apcu = extension_loaded('apcu');
$is_stat_enabled = ini_get('apc.stat'); $is_stat_enabled = ini_get('apc.stat');
$issue_key = null; $issue_key = null;
if ($is_stat_enabled && !$is_dev) { if ($is_stat_enabled && !$is_dev && !$is_apcu) {
$issue_key = 'extension.apc.stat-enabled'; $issue_key = 'extension.apc.stat-enabled';
$short = pht("'apc.stat' Enabled"); $short = pht("'apc.stat' Enabled");
$long = pht("'apc.stat' Enabled in Production"); $long = pht("'apc.stat' Enabled in Production");
@ -56,7 +57,7 @@ final class PhabricatorAPCSetupCheck extends PhabricatorSetupCheck {
"updates safer (PHP won't read in the middle of a 'git pull').\n\n". "updates safer (PHP won't read in the middle of a 'git pull').\n\n".
"(If you are developing for Phabricator, leave 'apc.stat' enabled but ". "(If you are developing for Phabricator, leave 'apc.stat' enabled but ".
"enable 'phabricator.developer-mode'.)"); "enable 'phabricator.developer-mode'.)");
} else if (!$is_stat_enabled && $is_dev) { } else if (!$is_stat_enabled && $is_dev && !$is_apcu) {
$issue_key = 'extension.apc.stat-disabled'; $issue_key = 'extension.apc.stat-disabled';
$short = pht("'apc.stat' Disabled"); $short = pht("'apc.stat' Disabled");
$long = pht("'apc.stat' Disabled in Development"); $long = pht("'apc.stat' Disabled in Development");

View file

@ -79,6 +79,32 @@ final class PhabricatorConfigCacheController
if ($version) { if ($version) {
$properties->addProperty(pht('Version'), $this->renderInfo($version)); $properties->addProperty(pht('Version'), $this->renderInfo($version));
} }
if ($cache->getName() === null) {
return;
}
$mem_total = $cache->getTotalMemory();
$mem_used = $cache->getUsedMemory();
if ($mem_total) {
$percent = 100 * ($mem_used / $mem_total);
$properties->addProperty(
pht('Memory Usage'),
pht(
'%s of %s',
phutil_tag('strong', array(), sprintf('%.1f%%', $percent)),
phutil_format_bytes($mem_total)));
}
$entry_count = $cache->getEntryCount();
if ($entry_count !== null) {
$properties->addProperty(
pht('Cache Entries'),
pht('%s', new PhutilNumber($entry_count)));
}
} }
private function renderIssues(array $issues) { private function renderIssues(array $issues) {