-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Cache] fix warming up cache.system and apcu #30331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
nicolas-grekas
commented
Feb 21, 2019
•
edited
Loading
edited
Q | A |
---|---|
Branch? | 4.2 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #29601, #29877 |
License | MIT |
Doc PR | - |
0564302
to
70b6994
Compare
@@ -108,16 +108,12 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) { | |||
*/ | |||
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null) | |||
{ | |||
if (null === self::$apcuSupported) { | |||
self::$apcuSupported = ApcuAdapter::isSupported(); | |||
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no PhpFilesAdapter::isSupported();
falling back to FilesystemAdapter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, unconditional is simpler and we don't care if you don't have opcache :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but, if the user does not have opcache or apcu, then you get no caching at all? possible hard to debug? up to the user to manually configure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just looked at it does sort of fallback to filesystem in 4.1 FYI
symfony/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
Lines 89 to 123 in a57ce22
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null) | |
{ | |
if (null === self::$apcuSupported) { | |
self::$apcuSupported = ApcuAdapter::isSupported(); | |
} | |
if (!self::$apcuSupported && null === self::$phpFilesSupported) { | |
self::$phpFilesSupported = PhpFilesAdapter::isSupported(); | |
} | |
if (self::$phpFilesSupported) { | |
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory); | |
if (null !== $logger) { | |
$opcache->setLogger($logger); | |
} | |
return $opcache; | |
} | |
$fs = new FilesystemAdapter($namespace, $defaultLifetime, $directory); | |
if (null !== $logger) { | |
$fs->setLogger($logger); | |
} | |
if (!self::$apcuSupported) { | |
return $fs; | |
} | |
$apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version); | |
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { | |
$apcu->setLogger(new NullLogger()); | |
} elseif (null !== $logger) { | |
$apcu->setLogger($logger); | |
} | |
return new ChainAdapter([$apcu, $fs]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you don't have opcache, you don't care about that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no opcache means you will still have the cache - but php will parse the files all the time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes! gotcha.
Maybe related? #29877 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming this fix brings back my test suite runtime from 4.2 amount (9:25) back to 4.1 amount (4:10).
Since it's a regression, a test is probably required to avoid having it reappear?
I don't think a test case would have prevented the change - I would have changed the tests at the time actually. |
@@ -108,16 +108,12 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) { | |||
*/ | |||
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
Does not seem to be precise anymore.
I meant adding a test would prevent a future regression. Also, this doesn't seem to fix #29877 since that issue is due to incorrectly detecting APCu in CLI. |
70b6994
to
b0a85ad
Compare
This PR was merged into the 4.2 branch. Discussion ---------- [Cache] fix warming up cache.system and apcu | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29601, #29877 | License | MIT | Doc PR | - Commits ------- b0a85ad [Cache] fix warming up cache.system and apcu