Skip to content
Permalink
Browse files

minor #34399 [HttpKernel] dont check cache freshness more than once p…

…er process (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpKernel] dont check cache freshness more than once per process

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

While running some functional tests in a loop, I noticed that half the time is spent computing cache freshness. This makes no sense - this mechanism is supposed to run once per process.

Here is the Blackfire comparison:
https://blackfire.io/profiles/compare/a4f2eb44-ae85-440b-ae87-edf43c2b2ef7/graph

![image](https://user-images.githubusercontent.com/243674/68955196-c5667780-07c5-11ea-9a19-f8e765664a8e.png)

Commits
-------

7f9556c [HttpKernel] dont check cache freshness more than once per process
  • Loading branch information
fabpot committed Nov 15, 2019
2 parents ca9a3a4 + 7f9556c commit 1374abd6e8c1fba158c240d5dbf655bfe57a4cd1
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/Symfony/Component/HttpKernel/Kernel.php
@@ -74,6 +74,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
private $requestStackSize = 0;
private $resetServices = false;
private static $freshCache = [];
const VERSION = '4.4.0-DEV';
const VERSION_ID = 40400;
const MAJOR_VERSION = 4;
@@ -511,7 +513,9 @@ protected function initializeContainer()
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
try {
if (file_exists($cachePath) && \is_object($this->container = include $cachePath) && (!$this->debug || $cache->isFresh())) {
if (file_exists($cachePath) && \is_object($this->container = include $cachePath)
&& (!$this->debug || (self::$freshCache[$k = $cachePath.'.'.$this->environment] ?? self::$freshCache[$k] = $cache->isFresh()))
) {
$this->container->set('kernel', $this);
error_reporting($errorLevel);

0 comments on commit 1374abd

Please sign in to comment.
You can’t perform that action at this time.