When should I use the Magento Compiler

39

4

I often see people mention they use the compiler feature of Magento.

I do never and wonder, which cases you should use it and how much performance gain you have then.

[DISCLAIMER]: As I got an edit suggestion about this recently. This question is not about the magento2 di-compile, its not even slightly about magento2.

Flyingmana

Posted 2014-01-11T12:54:35.020

Reputation: 5 029

1

See my benchmarks with the compiler: https://www.byte.nl/blog/should-i-use-the-magento-compiler/

– Willem – 2014-11-08T22:03:49.557

1your apc config is missing, also we now have the opcache module in current versions and there is no supported php version which works with apc anymore.

Software changes, so do solutions and workarounds. – Flyingmana – 2014-11-09T00:20:10.310

Answers

39

[DISCLAIMER] This answer is only meant for the compiler in Magento 1, the compiler in Magento 2 has a complete different purpose/effect

You should use it never.

Because PHP has developed several mechanics to improve applications containing lots of files.

Means: the php opCache in current php version gives way better performance improvements, if correctly configured. For example to use a high enough limit for cached files. Also the opCache has improvements for functions accessing the filesystem which work on a deeper level then aoe_classpathcache and improves performance even more.

In the end we have an autoloading which does not need more then a few ms without the compiler. There are even cases, where the compiler did harm to performance. Not to mention the crazy time consuming problems to debug applications using the compiler.

also, the opCache does not only improve autoloading, the filesystem function optimizations even improve template and layout file loading.

http://php.net/manual/en/opcache.configuration.php

Flyingmana

Posted 2014-01-11T12:54:35.020

Reputation: 5 029

2So, you suggest to disable compilation, clear compiled files, and use opCache instead? – perissf – 2014-01-11T17:10:03.640

1if you summarize it, yes – Flyingmana – 2014-01-11T17:11:31.670

3The Compiler is a kludge most useful with 1.4.1.1, 1.4.2.0 and possibly 1.5.1.0 versions. Starting with 1.5.1.0 forward, code optimization started to make it less effectual. Somewhere around 1.6 or 1.7, somebody did A/B testing and found that it can actually slow the system down under certain server configurations. – Fiasco Labs – 2014-01-11T18:34:31.197

3Two settings for the PHP interpreter to help with the bazillions of files that can be done if you have system access or can get your hosting provider to make the change for you -> realpath_cache_size=64k and realpath_cache_ttl=3600. 64k seems to be the sweet spot, people have recommended more, but performance testing shows it's a waste of memory. – Fiasco Labs – 2014-01-11T18:43:21.793

2@FiascoLabs Do you have a link/source to your "A/B testing" figures? It would be nice to see. – Aram Papazian – 2015-01-21T15:00:30.827

11

"When should I use the Magento Compiler"

If for some reason your system does not have a PHP Accelerator installed ( unlikely but possible )

If your running a very old version of magento ( you really shouldn't be )

Why should you keep it disabled ?

I totaly agree with Fiasco Labs comment above. While you didn't give your magento version number, this is true for all magento (CE) versions over 1.6.1, if you enable the compiler on a system that already has a php accelerator ( like PHP-APC etc ) your entire store, from admin pages right through to a customer checking out will be measurably slower, worse yet , many of the plugins/mods you find at the magento connect will not function correctly with compiler active.

In short, in 2014 there is never any good reason to enable the compiler.

Alistair

Posted 2014-01-11T12:54:35.020

Reputation: 326