-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Feature/parallelization #414
Feature/parallelization #414
Conversation
@50bhan Wanna review this one? |
@nunomaduro Sure, I'll check it out tomorrow. |
Perfect work @Jibbarth 👍 Really like the approach and implementation is clean as always. I have some comments though. |
Regarding performance, currently we are looking in cache for files at I did a test and you can check the result: https://blackfire.io/profiles/8dcc20f6-2435-4161-896e-92513fa2ece6/graph . |
@50bhan I had in mind to check if first file and last file had cache, but your idea is more clever 👍 |
In case phpinsights is launched by artisan
Anyone who use Windows can help me to test this PR ? It's pretty simple : On an other projectLaunch this command to add the fork repository in composer composer config repositories.phpinsights vcs https://github.com/jibbarth/phpinsights Then require phpinsights on correct branch : composer require nunomaduro/phpinsights:dev-feature/parallelization On phpinsights repogit remote add jibbarth [email protected]:Jibbarth/phpinsights.git
git fetch jibbarth
git checkout feature/parallelization |
I can test tomorrow on a bigger project. Will reply with the results |
Stable versionFinished in about 2 minutes I was unable to run parallelized version though.In Process.php line 338: [Symfony\Component\Process\Exception\RuntimeException] Exception trace:
|
I guess that project is just too big 😀 Tried to dump the syntax check command and run it manually.
|
Might be the culprit https://stackoverflow.com/a/29359348/3805289 . There is a limit on command length. Even when I try to paste the command to windows terminal it already warns about the command being longer then 5KiB. |
@ekvedaras Thanks you so much for testing this ! 🤗 If I understand, the bug came from the SyntaxCheck insight which was added in #373 ? Do you reproduce it on Can you exclude the insight You are probably right about command lenght, that's something we should care about 😕 |
I tested again on a smaller project. Not a supper big difference. The cached version ran instantly of course :)) My laptop was not completely idle, but I tried to close most of the apps. |
@ekvedaras You are right, we used I also reduce size of args by passing array of files to analyze by thread in the cache, so we should no longer had problem about command size. |
@ekvedaras Thanks you so much for helping me to test this feature 🙏 @50bhan @olivernybroe I think this PR is ready for review 😇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work @Jibbarth!
Just tested it out locally and it worked perfectly fine on my mac.
I'll say this is ready now 🥇
And thanks to @ekvedaras for helping out on this 👍
Great job @Jibbarth 👍 I think everything looks great and ready to merge! |
Alright. @Jibbarth You got green light to merge it in 👍 |
Thank you all 🙌 |
This PR add parallelization feature.
No external dependencies added, I create a new hidden command 'internal:processors' that launch code sniffer and CS fixer on a list of files.
The runner create as much as it can be new processes for this new command by retrieving number of CPU core, and launch them in parallel.
The new command store all details and fixed issues in cache, then the runner load issues from cache.
Please note that is do only for CodeSniffer and CSFixer processors.
I cannot add Insights instances in cache because there is a problem to cache SplFileInfo (not serializable), so each process need to reinstance them.
Let's talk about performance now.
Gain without cache : https://blackfire.io/profiles/compare/21eebd42-e83c-4bb4-99ad-8e717f42e6e9/graph
![image](https://user-images.githubusercontent.com/3168281/85223203-466f9800-b3c1-11ea-9105-6fb0c61fa558.png)
=>
When cache is already set, I loose slight performance: https://blackfire.io/profiles/compare/6dd977d1-c140-4016-a536-f03274744eca/graph
Maybe should we didn't launch subprocess in this case.
Edit : We bypass now launching subprocess for files that are already in cache 👍
TODO :
phpinsights.threads
option (in stubs)artisan insights