@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make disk-based setup caches more correct (but slower)

Summary:
Fixes T9599. When APC/APCu are not available, we fall back to a disk-based cache.

We try to share this cache across webserver processes like APC/APCu would be shared in order to improve performance, but are just kind of guessing how to coordinate it. From T9599, it sounds like we don't always get this right in every configuration.

Since this is complicated and error prone, just stop trying to do this. This cache has bad performance anyway (no production install should be using it), and we have much better APC/APCu setup instructions now than we did when I wrote this. Just using the PID is simpler and more correct.

Test Plan:
- Artificially disabled APC.
- Reloaded the page, saw all the setup stuff run.
- Reloaded the page, saw no setup stuff run (i.e., cache was hit).
- Restarted the webserver.
- Reloaded the page, saw all the setup stuff run.
- Reloaded again, got a cache hit.

I don't really know how to reproduce the exact problem with the parent PID not working, but from T9599 it sounds like this fixed the issue and from my test plan we still appear to get correct behavior in the standard/common case.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9599

Differential Revision: https://secure.phabricator.com/D14302

+7 -33
+4 -32
src/applications/cache/PhabricatorCaches.php
··· 206 206 // otherwise (we desire this property to give the cache the best hit rate 207 207 // we can). 208 208 209 - // In some setups, the parent PID is more stable and longer-lived that the 210 - // PID (e.g., under apache, our PID will be a worker while the ppid will 211 - // be the main httpd process). If we're confident we're running under such 212 - // a setup, we can try to use the PPID as the basis for our cache instead 213 - // of our own PID. 214 - $use_ppid = false; 215 - 216 - switch (php_sapi_name()) { 217 - case 'cli-server': 218 - // This is the PHP5.4+ built-in webserver. We should use the pid 219 - // (the server), not the ppid (probably a shell or something). 220 - $use_ppid = false; 221 - break; 222 - case 'fpm-fcgi': 223 - // We should be safe to use PPID here. 224 - $use_ppid = true; 225 - break; 226 - case 'apache2handler': 227 - // We're definitely safe to use the PPID. 228 - $use_ppid = true; 229 - break; 230 - } 209 + // Unfortunately, we don't have a very good strategy for minimizing the 210 + // churn rate of the cache. We previously tried to use the parent process 211 + // PID in some cases, but this was not reliable. See T9599 for one case of 212 + // this. 231 213 232 214 $pid_basis = getmypid(); 233 - if ($use_ppid) { 234 - if (function_exists('posix_getppid')) { 235 - $parent_pid = posix_getppid(); 236 - // On most systems, normal processes can never have PIDs lower than 100, 237 - // so something likely went wrong if we we get one of these. 238 - if ($parent_pid > 100) { 239 - $pid_basis = $parent_pid; 240 - } 241 - } 242 - } 243 215 244 216 // If possible, we also want to know when the process launched, so we can 245 217 // drop the cache if a process restarts but gets the same PID an earlier
+3 -1
src/applications/cache/spec/PhabricatorDataCacheSpec.php
··· 63 63 private function initNoneSpec() { 64 64 if (version_compare(phpversion(), '5.5', '>=')) { 65 65 $message = pht( 66 - 'Installing the "APCu" PHP extension will improve performance.'); 66 + 'Installing the "APCu" PHP extension will improve performance. '. 67 + 'This extension is strongly recommended. Without it, Phabricator '. 68 + 'must rely on a very inefficient disk-based cache.'); 67 69 68 70 $this 69 71 ->newIssue('extension.apcu')