I am facing problem from last few months that in my local environment the command cache:clear is incredibly slow. Many times it takes more than a minute. I tried it with both XAMPP and WAMP but It didn't help. I tried to solve by removing different services and bundles but situation remains same.
At the end I found the problem is directly proportionate to the number of Twig files I have in my Resources/Views Folder. I even created a new symfony project with standard command
composer create-project symfony/framework-standard-edition test-performance-project "2.7.*"
and created a simple standard controller and twig file to check my hypothesis. The more twig files I added in Resources/Views Folder, the slower the cache:clear command was (More or less proportional). Is there a way to prevent this because in our project we have high number of twig files in our Resources folder.
I am using
Windows 10 PHP 7.0.15 Symfony 2.7.23 Twig 1.31.0
Any help will be highly appreciated :)
I had similar issue with xdebug enabled in my cli environment. Twig parsing does a lot of iterations over template files so xdebug has a huge impact on twig cache generation performance.
Try to comment out this line in your php cli configuration:
;zend_extension=xdebug.so
Things I did to improve performance on windows 10, while keeping xdebug on.
enabled opcache
disabled xdebug.remote_autostart
added x-debug helper extension
Hint: if you have xdebug extension with remote_autostart 1, you should keep listener in your IDE always ON, even if you don't have any breakpoints, otherwise everything will run extremely slow (see case 6).
Some tests using a small symfony 4.2 project, in dev mode, time is DomContentLoaded taken from Chrome:
I use case 1 usually and when I need to debug I switch to case 2. Cases 3, 4, 5, 6 are relevant for people who might not be aware of implications of IDE listener and debug cookie.
I tested the same project with Windows Subsystem for Linux (WSL) enabled and got some improvements. load times when no caches were something like:
overall WSL improved everything, reducing load time by 50%.
PS: for WSL to work properly you will have to disable Windows Defender Real Time protection, otherwise everything will go 2x slower than without WSL. Maybe there are some options to keep Real Time protection on and exclude WSL, but I don't know at this point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With