Page MenuHomePhabricator

Provide a builtin APC / OpCache diagnostics page and improve OpCache support
Closed, ResolvedPublic

Description

There's currently no diagnostic UI for APC. Trim down a version of apc.php that doesn't expose cache keys or cache content.

Event Timeline

epriestley claimed this task.
epriestley raised the priority of this task from to Normal.
epriestley updated the task description. (Show Details)
epriestley added a project: Setup.
epriestley renamed this task from Provide a builtin APC diagnostics page to Provide a builtin APC / OpCache diagnostics page and improve OpCache support.Aug 25 2014, 3:03 AM
epriestley added subscribers: ide, asherkin, mbishopim3.

◀ Merged tasks: T4080.

I merged T4080 here because my half-diff of this ended up covering a lot of the territory there anyway.

Support Impact APC/OpCache have a dramatic impact on performance but are not straightforward to configure correctly.

APC is mostly-dead for php >= 5.4, and OpCache is "core" and "supported" for php >=5.5.

Being "core" and "supported" only seems to mean "The code is in there, and it builds and it's possible to get it work if you're lucky and know the right spells", because it builds an .so file and puts it in a random place, and doesn't try to load it.


I got my build-from-source-script to work it (for php 5.5.18) by adding this post-build steps:

cd $INSTALL_ROOT  # Wherever 'make install' put php
mv lib/php/extensions/*/*.so lib/php/extensions/    # In my config, this is just one file, opcache.so
rmdir lib/php/extensions/*
echo "zend_extension = $PREFIX/lib/php/extensions/opcache.so" >> etc/php.ini

And that's about it. No special arguments for ./configure, and the default config is "use for http mode, do not use for cli".

My Phabricator instance started going really slow. The Dark Console revealed that all the configuration checks were running with every page load (e.g. git checks, pygments, etc). Further investigation showed that the APC was not working. After some helpful tips from @epriestley, I was able to fix it. Here's the blurb I added to my php.ini:

; NOTE(keir mar 5/2015): APC seems to have broken on PHP 5.3.0; error messages:
;
; [Fri Mar 06 01:26:21 2015] [error] [client 63.232.3.122]   #8 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:19]
; [Fri Mar 06 01:26:21 2015] [error] [client 63.232.3.122] [2015-03-05 17:26:21] ERROR 2: apc_store(): Potential cache slam averted for key 'phabricator.setup.needs-repair' at [/home/ubuntu/phabricator/libphutil/src/cache/PhutilAPCKeyValueCache.php:36]
;
; Suggested solution from:
; http://stackoverflow.com/questions/4983370/php-apc-potential-cache-slam-averted-for-key
;
; I used this script to figure out that it didn't work, under phabricator/support/debug.php which appeared as phabricator.locu.com/debug/
;
;   <?php
;   error_reporting(E_ALL | E_STRICT);
;   $key = "i_am_a_banana";
;   echo "\nFetching: " . apc_fetch($key) . "\n";
;   echo "Storing: " . apc_store($key, "yes i am") . "\n";
;
apc.write_lock = 1
apc.slam_defense = 0

This seems to be in relatively good shape. Some possible future work:

  • Offer advice on user cache sizes?
  • PHP 5.6 may make this even more complicated?