diff --git a/src/applications/cache/spec/PhabricatorCacheSpec.php b/src/applications/cache/spec/PhabricatorCacheSpec.php --- a/src/applications/cache/spec/PhabricatorCacheSpec.php +++ b/src/applications/cache/spec/PhabricatorCacheSpec.php @@ -7,6 +7,10 @@ private $version; private $issues = array(); + private $usedMemory = 0; + private $totalMemory = 0; + private $entryCount = null; + public function setName($name) { $this->name = $name; return $this; @@ -50,4 +54,33 @@ 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; + } + + + } diff --git a/src/applications/cache/spec/PhabricatorDataCacheSpec.php b/src/applications/cache/spec/PhabricatorDataCacheSpec.php --- a/src/applications/cache/spec/PhabricatorDataCacheSpec.php +++ b/src/applications/cache/spec/PhabricatorDataCacheSpec.php @@ -21,6 +21,7 @@ if (ini_get('apc.enabled')) { $spec->setIsEnabled(true); + self::getAPCCommonSpec($spec); } else { $spec->setIsEnabled(false); $spec->newIssue( @@ -41,6 +42,7 @@ if (ini_get('apc.enabled')) { $spec->setIsEnabled(true); + self::getAPCCommonSpec($spec); } else { $spec->setIsEnabled(false); $spec->newissue( @@ -70,4 +72,13 @@ 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'])); + } + } diff --git a/src/applications/cache/spec/PhabricatorOpcodeCacheSpec.php b/src/applications/cache/spec/PhabricatorOpcodeCacheSpec.php --- a/src/applications/cache/spec/PhabricatorOpcodeCacheSpec.php +++ b/src/applications/cache/spec/PhabricatorOpcodeCacheSpec.php @@ -21,6 +21,12 @@ if (ini_get('apc.enabled')) { $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 { $spec->setIsEnabled(false); $spec->newIssue( @@ -41,6 +47,16 @@ if (ini_get('opcache.enable')) { $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 { $spec->setIsEnabled(false); $spec->newissue( diff --git a/src/applications/config/check/PhabricatorAPCSetupCheck.php b/src/applications/config/check/PhabricatorAPCSetupCheck.php --- a/src/applications/config/check/PhabricatorAPCSetupCheck.php +++ b/src/applications/config/check/PhabricatorAPCSetupCheck.php @@ -40,10 +40,11 @@ } $is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode'); + $is_apcu = extension_loaded('apcu'); $is_stat_enabled = ini_get('apc.stat'); $issue_key = null; - if ($is_stat_enabled && !$is_dev) { + if ($is_stat_enabled && !$is_dev && !$is_apcu) { $issue_key = 'extension.apc.stat-enabled'; $short = pht("'apc.stat' Enabled"); $long = pht("'apc.stat' Enabled in Production"); @@ -56,7 +57,7 @@ "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 ". "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'; $short = pht("'apc.stat' Disabled"); $long = pht("'apc.stat' Disabled in Development"); diff --git a/src/applications/config/controller/PhabricatorConfigCacheController.php b/src/applications/config/controller/PhabricatorConfigCacheController.php --- a/src/applications/config/controller/PhabricatorConfigCacheController.php +++ b/src/applications/config/controller/PhabricatorConfigCacheController.php @@ -79,6 +79,32 @@ if ($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) {