Introducing up-to 16 Times Faster Easy Coding Standard

Found a typo? Edit me

Do you use Easy Coding Standard? Do you find extremely useful and easy to use, but a little slow on a huge code base?

If you follow me carefully on Twitter, you already know that the ECS got a new parallel run feature. I wanted to test it in a circle of early adopters first, so we make the run as smooth as possible for you.

Today, we're sharing the ECS Parallel run with the public, so you can cut down ECS run times from minutes to seconds.

Have you already updated #ecs to parallel run? ☺️

This is what you're missing out ↓

— Tomas Votruba (@VotrubaT) October 7, 2021

Bottle Neck?

Coding Standard tools are very fast in processing single file. They parse PHP code to tokens, analyze tokens in a foreach loop, and report found issues. The performance hit is in the number of processed files. If we have 10 files, the 1st file is processed. The 2nd file cannot start until the 1st file is finished.

Fortunately, this architecture has huge potential in performance improvement once we add a parallel run. That's what I've been working for July and August this summer. Huge thanks to Ondrej Mirtes for inspiration in PHPStan parallel run.

ECS is now X-times Faster!

...where X = number of your CPU threads. What does it mean?

You might think: "such CPUs must be expensive and available only for high-end laptops". You'll be surprised.

Don't Take My Word for It

We've got few reports from our early adopters. How does ECS handle their projects?

Thanks, @VotrubaT for adding parallel run to ECS 🥰. Running on Shopware 6 needs now 24s instead of 229s.

— Shyim (@Shyim97) October 11, 2021

Enjoy Parallel ECS in Your Project Today

How to add this feature to your project?

Be sure to use at least ECS 9.4.70:

composer require symplify/easy-coding-standard:^9.4.70

And enable a new parameter in your ecs.php config file:

 use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
 use Symplify\EasyCodingStandard\ValueObject\Option;

 return function (ContainerConfigurator $containerConfigurator): void {
     $parameters = $containerConfigurator->parameters();
+    $parameters->set(Option::PARALLEL, true);

That's it!

The parallel run might become enabled by default in ECS 10. We have enough time to test it on real projects and make it reliable till then. So far, it has been tested on Linux and Windows. If you're lucky enough to find the edge case, please let us know in issues, so we can cover it.

Happy coding!

Have you find this post useful? Do you want more?

Follow me on Twitter, RSS or support me on GitHub Sponsors.