We've upgraded to version 5 and noticed a massive impact on performance.
By turning on and off the sniffs one by one we managed to track down the problem to the sniffs
ReferenceThrowableOnly, FullyQualifiedGlobalConstants, FullyQualifiedGlobalFunctions and UnusedUses. With these sniffs enabled, the time needed to run all checks increases from 30 seconds to more than 10 minutes, which is impractical.
I've compared the version 4.8.8 against 5.0.0, and there were a lot of changes. Any guess about what may have caused such an impact on performance?
Difficult to guess without the code.
I have published a repo, with a single class that reproduces the problem.
Test with all SlevomatCodingStandard rules:
Test with version 5.0.0, excluding the mentioned rules:
ReferenceThrowableOnly: 40.84 secondsFullyQualifiedGlobalConstants: 35.91 secondsFullyQualifiedGlobalFunctions: 37.06 secondsUnusedUses: 34.95 secondsI didn't find any obvious problem when running the phpcs with -vv, the processing log is almost identical.
Here are Blackfire profiles for each run of:
vendor/bin/phpcs --standard=all.phpcs.xml --sniffs=SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions
Ran on Windows, PHP 7.3 NTS.
Slevomat CS 4.8.7: https://blackfire.io/profiles/091c61ff-d6eb-482f-b2da-4f08966b3639/graph
Slevomat CS 5.0.0: https://blackfire.io/profiles/fe70c208-dbfe-49c2-bf59-51b5486bbfef/graph
The obvious problem is massive performance hit by calling File::findPrevious().
Hmm, I guess it's caused by https://github.com/slevomat/coding-standard/commit/248bd37cab72cdd383600d165b61378ac655e2c2#diff-fc1ee625359b71f7fe46fd9dc33b8fd6R148
It looks I will have to implement some cache.
Can you please try dev-master?
Way better! This version runs in 16.59 seconds.
We're looking forward to the new release :)
Thank you, @kukulich.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I didn't find any obvious problem when running the phpcs with
-vv, the processing log is almost identical.Here are Blackfire profiles for each run of:
Ran on Windows, PHP 7.3 NTS.
Slevomat CS 4.8.7: https://blackfire.io/profiles/091c61ff-d6eb-482f-b2da-4f08966b3639/graph
Slevomat CS 5.0.0: https://blackfire.io/profiles/fe70c208-dbfe-49c2-bf59-51b5486bbfef/graph
The obvious problem is massive performance hit by calling File::findPrevious().