Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Cache] Unconditionally use PhpFilesAdapter for system pools#27549

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@nicolas-grekas
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

Now that we're about to leverage OPCache shared memory even for objects (see#27543), there's no reason anymore to use APCu for system caches. Let's remove some complexity here.

As a bonus, this makes system caches pruneable using thecache:pool:prune command.

@palex-fpt
Copy link

There is one problem with PhpFilesAdapter - it does not use opcache till next request.

 $cache->set('key', 'value'); $cache->get('key'); // load directly from file, as file with timestamp >= request start time is not opcached.

@nicolas-grekasnicolas-grekasforce-pushed thecache-deprec-system-factory branch from8cf36c7 to19c30c9CompareJune 8, 2018 05:46
@nicolas-grekas
Copy link
MemberAuthor

There is one problem with PhpFilesAdapter - it does not use opcache till next request.

After having a deeper look, it does, but only if the file's mtime is in the past. This is now fixed. Thanks for the hint.

@palex-fpt
Copy link

palex-fpt commentedJun 8, 2018
edited
Loading

to pass tests it should invalidate cache on file deletion (opcache_invalidate should be called before file is unlinked)

@nicolas-grekasnicolas-grekasforce-pushed thecache-deprec-system-factory branch from19c30c9 todf6dddbCompareJune 8, 2018 06:00
@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedJun 8, 2018
edited
Loading

to pass tests it should invalidate cache on file deletion (opcache_invalidate should be called before file is unlinked)

That would open race conditions (invalidating, then a concurrent request reloads the legacy file, then we write but this is ignored).Tests do pass so not sure what you meant (hum, I missed the failures on FrameworkBundle, I'll have a look.)

@nicolas-grekasnicolas-grekasforce-pushed thecache-deprec-system-factory branch fromdf6dddb to647cfccCompareJune 8, 2018 06:13
@nicolas-grekas
Copy link
MemberAuthor

Hum, dunno why but tests pass locally and not the CI. I added the call you suggested but still red. Any idea why?

@palex-fpt
Copy link

calls to $cache->delete() or $cache->clear() unlinks files. but opcache is still has file cached. Andlist($expiresAt, $values[$id]) = include $file; returns data. Tests pass when opcache is not working (opcache_cli = false)

@palex-fpt
Copy link

palex-fpt commentedJun 8, 2018
edited
Loading

Index: src/Symfony/Component/Cache/Traits/PhpFilesTrait.phpIDEA additional info:Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP<+>UTF-8===================================================================--- src/Symfony/Component/Cache/Traits/PhpFilesTrait.php(revision 3a2eb0d9514f0b322ab31a128aa48b9f89e28d50)+++ src/Symfony/Component/Cache/Traits/PhpFilesTrait.php(date 1528439846061)@@ -23,7 +23,9 @@  */ trait PhpFilesTrait {-    use FilesystemCommonTrait;+    use FilesystemCommonTrait {+        doUnlink as doFsUnlink;+    }      private $includeHandler;     private $zendDetectUnicode;@@ -155,4 +157,13 @@          return $ok;     }++    protected function doUnlink($file)+    {+        $allowCompile = 'cli' !== PHP_SAPI || ini_get('opcache.enable_cli');+        if ($allowCompile) {+            @opcache_invalidate($file, true);+        }+        return $this->doFsUnlink($file);+    } }Index: src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.phpIDEA additional info:Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP<+>UTF-8===================================================================--- src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php(revision 3a2eb0d9514f0b322ab31a128aa48b9f89e28d50)+++ src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php(date 1528439709379)@@ -56,7 +56,7 @@         $ok = true;          foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS)) as $file) {-            $ok = ($file->isDir() || @unlink($file) || !file_exists($file)) && $ok;+            $ok = ($file->isDir() || @$this->doUnlink($file) || !file_exists($file)) && $ok;         }          return $ok;@@ -71,7 +71,7 @@          foreach ($ids as $id) {             $file = $this->getFile($id);-            $ok = (!file_exists($file) || @unlink($file) || !file_exists($file)) && $ok;+            $ok = (!file_exists($file) || @$this->doUnlink($file) || !file_exists($file)) && $ok;         }          return $ok;@@ -122,7 +122,12 @@             parent::__destruct();         }         if (null !== $this->tmp && file_exists($this->tmp)) {-            unlink($this->tmp);+            $this->doUnlink($this->tmp);         }     }++    protected function doUnlink($file)+    {+        return @unlink($file);+    } }

@nicolas-grekasnicolas-grekasforce-pushed thecache-deprec-system-factory branch from647cfcc to22bf5c3CompareJune 8, 2018 06:54
@nicolas-grekas
Copy link
MemberAuthor

Thanks, patch applied.

@palex-fpt
Copy link

opcache_invalidate should be called before unlink

@palex-fpt
Copy link

invalidate fails when file does not exits and opcache still contains file entry.

@nicolas-grekasnicolas-grekasforce-pushed thecache-deprec-system-factory branch 6 times, most recently fromd1f6da9 tocc1edabCompareJune 8, 2018 11:09
@nicolas-grekas
Copy link
MemberAuthor

Thanks, now green!

{
$this->file =$file;
$this->pool =$fallbackPool;
$this->zendDetectUnicode =ini_get('zend.detect_unicode');
Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasJun 8, 2018
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No need to deal withzend.detect_unicode anymore whenthis line is removed. Let's remove the related complexity and overhead.

@nicolas-grekasnicolas-grekasforce-pushed thecache-deprec-system-factory branch fromce1a15d toc91b778CompareJune 8, 2018 22:53
*
* @return AdapterInterface
*
* @deprecated since Symfony 4.2.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

no dot at the end (I know, our conventions are hard to follow :)).

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

updated

@nicolas-grekasnicolas-grekasforce-pushed thecache-deprec-system-factory branch fromc91b778 to51381e5CompareJune 11, 2018 07:58
@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commit51381e5 intosymfony:masterJun 11, 2018
fabpot added a commit that referenced this pull requestJun 11, 2018
… pools (nicolas-grekas)This PR was merged into the 4.2-dev branch.Discussion----------[Cache] Unconditionally use PhpFilesAdapter for system pools| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -Now that we're about to leverage OPCache shared memory even for objects (see#27543), there's no reason anymore to use APCu for system caches. Let's remove some complexity here.As a bonus, this makes system caches pruneable using the `cache:pool:prune` command.Commits-------51381e5 [Cache] Unconditionally use PhpFilesAdapter for system pools
@nicolas-grekasnicolas-grekas deleted the cache-deprec-system-factory branchJune 11, 2018 09:02
*/
publicstaticfunctioncreateSystemCache($namespace,$defaultLifetime,$version,$directory,LoggerInterface$logger =null)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.',__CLASS__),E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

shouldn't it be__METHOD__ ?

nicolas-grekas added a commit to nicolas-grekas/symfony that referenced this pull requestOct 10, 2018
…pter for system pools (nicolas-grekas)"This reverts commitd4f5d46, reversingchanges made to7e3b7b0.
fabpot added a commit that referenced this pull requestOct 10, 2018
…sAdapter for system pools" (nicolas-grekas)This PR was merged into the 4.2-dev branch.Discussion----------Revert "feature#27549 [Cache] Unconditionally use PhpFilesAdapter for system pools"This reverts commitd4f5d46, reversingchanges made to7e3b7b0.| Q             | A| ------------- | ---| Branch?       | 4.2| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -Reading#28800, I've just realized that#27549 breaks using system caches with read-only filesystem.Using ApcuAdapter makes system caches compatible with read-only filesystems.Note that this affects only non-warmed up pools, as the warmed-up ones use a faster `PhpArrayAdapter` in front.Commits-------dbc1230 Revert "feature#27549 [Cache] Unconditionally use PhpFilesAdapter for system pools (nicolas-grekas)"
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

5 participants

@nicolas-grekas@palex-fpt@fabpot@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp