Skip to content
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

cache warmup missing in Composer\ScriptHandler in 4.5 #59

Closed
fritzmg opened this issue Mar 13, 2018 · 14 comments
Closed

cache warmup missing in Composer\ScriptHandler in 4.5 #59

fritzmg opened this issue Mar 13, 2018 · 14 comments
Assignees
Labels
Milestone

Comments

@fritzmg
Copy link
Contributor

fritzmg commented Mar 13, 2018

In version 4.5, the cache:warmup was removed from

Contao\ManagerBundle\Composer\ScriptHandler::initializeApplication

Is there any particular reason why? This leaves the website in an inefficient state after a composer operation, if you do not manually run

vendor/bin/contao-console cache:warmup
@leofeyer
Copy link
Member

cache:clear also warms up the cache. They had deprecated it for a couple of weeks but later reverted the deprecation, so it is fine to use cache:clear only.

@fritzmg
Copy link
Contributor Author

fritzmg commented Mar 14, 2018

There still seems to be a difference. This is the state of var/cache/prod after cache:clear:

    annotations.map
    appProdProjectContainer.php
    appProdProjectContainer.php.meta
    appProdProjectContainerUrlGenerator.php
    appProdProjectContainerUrlGenerator.php.meta
    appProdProjectContainerUrlMatcher.php
    appProdProjectContainerUrlMatcher.php.meta
    Container2y5l8mc/
    contao/
    templates.php

And this is the state of the cache after cache:warmup:

    annotations.map
+   annotations.php
    appProdProjectContainer.php
    appProdProjectContainer.php.meta
    appProdProjectContainerUrlGenerator.php
    appProdProjectContainerUrlGenerator.php.meta
    appProdProjectContainerUrlMatcher.php
    appProdProjectContainerUrlMatcher.php.meta
+   bundles.map
    Container2y5l8mc/
    contao/
+   pools/
    templates.php
+   twig/

Furthermore, this is the average response time for the first request after cache:clear on my local environment:

  • 459.6ms

And this after cache:warmup:

  • 315.4ms

The latter provides an over 144ms better result.

@leofeyer
Copy link
Member

That's interesting. Which commands exactly did you run? You should compare

  • cache:clear

to

  • cache:clear --no-warmup
  • cache:warmup

@fritzmg
Copy link
Contributor Author

fritzmg commented Mar 14, 2018

I've tested the following way:

rm -rf var/cache/prod
vendor/bin/contao-console cache:clear

and

rm -rf var/cache/prod
vendor/bin/contao-console cache:warmup

I did this before each request to ensure consistency. I did it 5 times for each case and took the average response time.

Note: I have used rm -rf var/cache/prod to ensure that the cache is cleared properly (since at least under Windows errors can happen during cache:clear due to file or operating system shenanigans). cache:clear --no-warmup should be equal to rm -rf var/cache/prod.

@leofeyer
Copy link
Member

What is the content of the contao/ folder in each case?

@fritzmg
Copy link
Contributor Author

fritzmg commented Mar 14, 2018

The content of var/cache/prod/contao is identical in each case.

Btw., when using cache:clear, the pools folder will be generated on the first request. However, it will have much less content than with cache:warmup.

The twig folder is generated with the first back end request (since the back end uses twig templates in Contao 4.5).

annotations.php and bundles.map will also be generated on the first request.

@leofeyer
Copy link
Member

Hm, that does not make much sense, does it? Both cache:clear and cache:warmup will warm up the cache and they should not produce different results IMHO. Maybe a Symfony bug?

@fritzmg
Copy link
Contributor Author

fritzmg commented Mar 14, 2018

Can you reproduce it? May be it only occurs on Windows? I'll also try on a Linux machine.

@fritzmg
Copy link
Contributor Author

fritzmg commented Mar 14, 2018

I was actually unable to reproduce this on a Linux based shared hosting environment...

@leofeyer
Copy link
Member

Yes I can reproduce it. But both cache:clear and cache:warmup execute the same warmers, so I really don't understand it.

string(67) "Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer"
string(66) "Symfony\Bundle\FrameworkBundle\CacheWarmer\TranslationsCacheWarmer"
string(60) "Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer"
string(65) "Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer"
string(62) "Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer"
string(57) "Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheWarmer"
string(41) "Contao\CoreBundle\Cache\ContaoCacheWarmer"

@leofeyer leofeyer added the bug label Mar 14, 2018
@leofeyer leofeyer added this to the 4.5.7 milestone Mar 14, 2018
@leofeyer
Copy link
Member

Anyway, we should probably just re-add the cache:warmup.

@leofeyer leofeyer reopened this Mar 14, 2018
@fritzmg
Copy link
Contributor Author

fritzmg commented Mar 14, 2018

And --no-warmup to be safe?

@leofeyer
Copy link
Member

Yes. Basically the code from Contao 4.4.

static::executeCommand('cache:clear --no-warmup', $event);
static::executeCommand('cache:warmup', $event);

@leofeyer
Copy link
Member

Fixed in 77c85e2.

@leofeyer leofeyer modified the milestones: 4.5.7, 4.5 May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants