-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: Ability to run Fixer with parallel runner 🎉 #7777
Commits on May 15, 2024
-
Empty for now, because logic for running fixers must be moved here. Basically it's a PoC of command being hidden - works on PHP 7.4 and 8.3 with latest Composer packages on each version. Command's arguments/options are more or less what we need in the worker, but it may be changed later.
Configuration menu - View commit details
-
Copy full SHA for f48325b - Browse repository at this point
Copy the full SHA f48325bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 186bec4 - Browse repository at this point
Copy the full SHA 186bec4View commit details -
Extract factory method for linting aware file iterator
The same collection of files has to be determined for both sequential and parallel run. See PR7777#discussion_r1526648174
Configuration menu - View commit details
-
Copy full SHA for eebe4ef - Browse repository at this point
Copy the full SHA eebe4efView commit details -
Initial implementation of parallel analysis 🎉
It's working, but needs polishing here and there. It speeds up analysis significantly (like 5x for this codebase on my computer).
Configuration menu - View commit details
-
Copy full SHA for b788803 - Browse repository at this point
Copy the full SHA b788803View commit details -
Use sequential runner by default
Parallel runner must be introduced slowly, and start as an opt-in. When it's stable enough, we can change it to be default one.
Configuration menu - View commit details
-
Copy full SHA for c12f95f - Browse repository at this point
Copy the full SHA c12f95fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9fb0766 - Browse repository at this point
Copy the full SHA 9fb0766View commit details -
Auto detection for parallel config
Using `ParallelConfig::detect()` can be used for utilising all available resources. Tested by running analysis natively on the host and inside Docker (with core limit set on the OrbStack level). In both scenarios it detects available cores correctly.
Configuration menu - View commit details
-
Copy full SHA for 22d6bf3 - Browse repository at this point
Copy the full SHA 22d6bf3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2afff3b - Browse repository at this point
Copy the full SHA 2afff3bView commit details -
Pass analysis errors from worker to the main runner and report them t…
…o the error manager
Configuration menu - View commit details
-
Copy full SHA for 845b4ab - Browse repository at this point
Copy the full SHA 845b4abView commit details -
Configuration menu - View commit details
-
Copy full SHA for 32355df - Browse repository at this point
Copy the full SHA 32355dfView commit details -
Configuration menu - View commit details
-
Copy full SHA for d5c4283 - Browse repository at this point
Copy the full SHA d5c4283View commit details -
Configuration menu - View commit details
-
Copy full SHA for ea93685 - Browse repository at this point
Copy the full SHA ea93685View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6f11b20 - Browse repository at this point
Copy the full SHA 6f11b20View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6bdfa0e - Browse repository at this point
Copy the full SHA 6bdfa0eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 039a1f7 - Browse repository at this point
Copy the full SHA 039a1f7View commit details -
Configuration menu - View commit details
-
Copy full SHA for e265e51 - Browse repository at this point
Copy the full SHA e265e51View commit details -
Configuration menu - View commit details
-
Copy full SHA for 93935d9 - Browse repository at this point
Copy the full SHA 93935d9View commit details -
Configuration menu - View commit details
-
Copy full SHA for dd53801 - Browse repository at this point
Copy the full SHA dd53801View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1f892a6 - Browse repository at this point
Copy the full SHA 1f892a6View commit details -
Support cache in parallel analysis
Cache check is done during file iteration - if file is in cache and wasn't changed, then it's skip by iterator and doesn't even go to the worker. That's why `ReadonlyCacheManager` used on worker's side is a bit superfluous, but I thought it's safer to use it instead of `NullCacheManager`. Anyway, each file is stored to cache when worker reports analysis result to the parallelisation operator, so it's basically similar to sequential analysis, because file write is done only in one process.
Configuration menu - View commit details
-
Copy full SHA for d0364b1 - Browse repository at this point
Copy the full SHA d0364b1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 63529c2 - Browse repository at this point
Copy the full SHA 63529c2View commit details -
Apply Julien's suggestions from code review
Co-authored-by: Julien Falque <julien.falque@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 39a8c0e - Browse repository at this point
Copy the full SHA 39a8c0eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 41ed875 - Browse repository at this point
Copy the full SHA 41ed875View commit details -
Use
InvalidArgumentException
for parallelisation misconfiguration +…… PHPStan narrowed types
Configuration menu - View commit details
-
Copy full SHA for 34f3de0 - Browse repository at this point
Copy the full SHA 34f3de0View commit details -
Fix BC-break in
DirectoryInterface
Use absolute file path for reporting analysis result and convert it to relative path when processing on parallelisation operator's side. It gives the same effect in terms of caching, but does not require `DirectoryInterface::getAbsolutePath()`.
Configuration menu - View commit details
-
Copy full SHA for 4bee6dd - Browse repository at this point
Copy the full SHA 4bee6ddView commit details -
Report file analysis result per file instead of per chunk
It improves caching, because cache save can be triggered more frequently and errors or interrupting during processing large chunk won't cause analysis info being lost (which would lead to re-analysing file that was already processed).
Configuration menu - View commit details
-
Copy full SHA for e3726fb - Browse repository at this point
Copy the full SHA e3726fbView commit details -
Clean up parallel actions handling
- extract constants to dedicated class with more fitting name - use constants in every place where communication between runner and worker occurs
Configuration menu - View commit details
-
Copy full SHA for c9b75bf - Browse repository at this point
Copy the full SHA c9b75bfView commit details -
Dirty workaround for running sequential runner in tests
There were 2 problems: - when child processes were spawned, `ArgvInput` was created to pass the arguments/options to the worker, but when fix/check command was executed via command tester, `ArgvInput` was using PHPUnit's argv from top-level command (and was failing with "The "--configuration" option does not exist.") - Passing `InputInterface` instance from command to process (did an experiment with static property set in command to skip passing input through the Runner instance) was not enough because output was invalid and tests were failing. I hope we can figure out something better after discussion on code review 😉.
Configuration menu - View commit details
-
Copy full SHA for 4d1e7aa - Browse repository at this point
Copy the full SHA 4d1e7aaView commit details -
Some of the tests are little hacky at this point, maybe it's possible to refactor a bit to achieve better testability. Good enough for now, though.
Configuration menu - View commit details
-
Copy full SHA for 9d965ee - Browse repository at this point
Copy the full SHA 9d965eeView commit details -
Extract process creation to separate factory
Passing root process' input to the runner and then to `ProcessFactory` allows switching `InputInterface` implementation and test process creation.
Configuration menu - View commit details
-
Copy full SHA for 4d477ff - Browse repository at this point
Copy the full SHA 4d477ffView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2ec2ed8 - Browse repository at this point
Copy the full SHA 2ec2ed8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 19d5bf2 - Browse repository at this point
Copy the full SHA 19d5bf2View commit details -
Configuration menu - View commit details
-
Copy full SHA for cffeb97 - Browse repository at this point
Copy the full SHA cffeb97View commit details -
Allow wider range of React packages
Tested on: - PHP 8.3 - PHP 8.3 with --prefer-lowest - PHP 7.4 with --prefer-lowest
Configuration menu - View commit details
-
Copy full SHA for b92bb52 - Browse repository at this point
Copy the full SHA b92bb52View commit details -
Introduce
--sequential
option tofix
command- it can be helpful when using parallel config but there's need to disable it temporarily (it's easier to add option to the command than editing config file) - it solves the internal problem with parallel runner being used for running tests that operate on command's output (parallel run produces undeterministic output because files are not processed in the strict order)
Configuration menu - View commit details
-
Copy full SHA for df9184c - Browse repository at this point
Copy the full SHA df9184cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 24ac18b - Browse repository at this point
Copy the full SHA 24ac18bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 41cb3e0 - Browse repository at this point
Copy the full SHA 41cb3e0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3c9af57 - Browse repository at this point
Copy the full SHA 3c9af57View commit details -
Configuration menu - View commit details
-
Copy full SHA for b06ad0c - Browse repository at this point
Copy the full SHA b06ad0cView commit details -
Configuration menu - View commit details
-
Copy full SHA for a305038 - Browse repository at this point
Copy the full SHA a305038View commit details -
Configuration menu - View commit details
-
Copy full SHA for 53bd005 - Browse repository at this point
Copy the full SHA 53bd005View commit details -
Configuration menu - View commit details
-
Copy full SHA for f0918dd - Browse repository at this point
Copy the full SHA f0918ddView commit details -
Configuration menu - View commit details
-
Copy full SHA for f8798a5 - Browse repository at this point
Copy the full SHA f8798a5View commit details -
https://twitter.com/_Codito_/status/1763374111571472558 Needs more tests!
Configuration menu - View commit details
-
Copy full SHA for def6275 - Browse repository at this point
Copy the full SHA def6275View commit details -
Configuration menu - View commit details
-
Copy full SHA for cd8eb2f - Browse repository at this point
Copy the full SHA cd8eb2fView commit details -
Configuration menu - View commit details
-
Copy full SHA for a18b4e0 - Browse repository at this point
Copy the full SHA a18b4e0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2cec9a2 - Browse repository at this point
Copy the full SHA 2cec9a2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 21f4e28 - Browse repository at this point
Copy the full SHA 21f4e28View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2053e7f - Browse repository at this point
Copy the full SHA 2053e7fView commit details -
Configuration menu - View commit details
-
Copy full SHA for e9d5e73 - Browse repository at this point
Copy the full SHA e9d5e73View commit details -
Skip linting on file iteration in main process of parallel runner
The linting is done on the workers' side before fixers are applied, so we will collect any syntax errors anyway.
Configuration menu - View commit details
-
Copy full SHA for d5f6f47 - Browse repository at this point
Copy the full SHA d5f6f47View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4d3bf56 - Browse repository at this point
Copy the full SHA 4d3bf56View commit details -
Configuration menu - View commit details
-
Copy full SHA for 34308f9 - Browse repository at this point
Copy the full SHA 34308f9View commit details -
Configuration menu - View commit details
-
Copy full SHA for a766504 - Browse repository at this point
Copy the full SHA a766504View commit details -
Configuration menu - View commit details
-
Copy full SHA for eaa1354 - Browse repository at this point
Copy the full SHA eaa1354View commit details -
Configuration menu - View commit details
-
Copy full SHA for a4cc010 - Browse repository at this point
Copy the full SHA a4cc010View commit details -
Configuration menu - View commit details
-
Copy full SHA for cfbf0bb - Browse repository at this point
Copy the full SHA cfbf0bbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2d05341 - Browse repository at this point
Copy the full SHA 2d05341View commit details -
Configuration menu - View commit details
-
Copy full SHA for 71b089e - Browse repository at this point
Copy the full SHA 71b089eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 051b9ee - Browse repository at this point
Copy the full SHA 051b9eeView commit details -
- always expect CPU(s) usage info in the output - always use dist config for PHAR parallel test (because local config can use sequential analysis)
Configuration menu - View commit details
-
Copy full SHA for 763cc8b - Browse repository at this point
Copy the full SHA 763cc8bView commit details -
Configuration menu - View commit details
-
Copy full SHA for df35f4f - Browse repository at this point
Copy the full SHA df35f4fView commit details -
Configuration menu - View commit details
-
Copy full SHA for ee9def7 - Browse repository at this point
Copy the full SHA ee9def7View commit details -
Refactoring and cosmetic changes
* syntax sugar * sequential option - no shortcut, as we do not use shortcut for other any other option * explicitly mark `ProcessFactory::getCommandArgs` as `@private`, to indicate it shall not be called from outside of this class, ref PHP-CS-Fixer#7777 (comment) * `WorkerCommand` options written as single-liners, so unified as all other commands and easier to copy-paste * add explicit comment for hardcoded option * remove unused var * rename `ParallelRunnerConfigInterface` to `ParallelAwareConfigInterface` * make `ParallelConfig` only DTO and externalize factory methods to dedicated class * `Runner` - don't reevaluate `maxFixerPerProcess` in each loop * explicitly call generator, avoid simple 'job' as too similar to job-id * rename variables related to file chunks
Configuration menu - View commit details
-
Copy full SHA for c6ea784 - Browse repository at this point
Copy the full SHA c6ea784View commit details -
More strict approach in
WorkerCommand
* explicitly crash on unexpected parallel action * explicitly crash on unexpected events count, i.e. when someone wrongly refactors EventBus * no need to calculate relative path + validate if result has proper size * introduce `ErrorsManager::reportWorkerError()`: don't report `WorkerError` via `report(Error)` method
Configuration menu - View commit details
-
Copy full SHA for 97a2764 - Browse repository at this point
Copy the full SHA 97a2764View commit details -
Auto-detected parallel config by default for future mode or as an opt…
…-in via env variable
Configuration menu - View commit details
-
Copy full SHA for ab01e66 - Browse repository at this point
Copy the full SHA ab01e66View commit details -
Reuse existing cache hash to avoid IO read operation
* use cache nicely, without recalculation of hash * no need for read-only cache, anymore
Configuration menu - View commit details
-
Copy full SHA for 69b64be - Browse repository at this point
Copy the full SHA 69b64beView commit details -
Configuration menu - View commit details
-
Copy full SHA for f347f13 - Browse repository at this point
Copy the full SHA f347f13View commit details -
Configuration menu - View commit details
-
Copy full SHA for 077fd6b - Browse repository at this point
Copy the full SHA 077fd6bView commit details -
Clean up loop that re-reports errors from worker to main process' err…
…or manager - Remove invalid comment (no idea why it was here) - rename loop's variable to not confuse it with `WorkerError` class that represents unrecoverable errors on worker side
Configuration menu - View commit details
-
Copy full SHA for b7ac50d - Browse repository at this point
Copy the full SHA b7ac50dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5a0cc3e - Browse repository at this point
Copy the full SHA 5a0cc3eView commit details -
Flip naming convention for
ParallelAction
consts and improve themIt's actually more natural to name these actions after initiating side - when we're writing to the output, we should use action related to the place where we're writing, and when we're reading the message, action should point to the callee. See: PHP-CS-Fixer#7777 (comment)
Configuration menu - View commit details
-
Copy full SHA for 5069549 - Browse repository at this point
Copy the full SHA 5069549View commit details -
Configuration menu - View commit details
-
Copy full SHA for d613ade - Browse repository at this point
Copy the full SHA d613adeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7aa838b - Browse repository at this point
Copy the full SHA 7aa838bView commit details -
Configuration menu - View commit details
-
Copy full SHA for f63b4d5 - Browse repository at this point
Copy the full SHA f63b4d5View commit details -
Rework error handling in workers
- handled process errors (linting, failed fixes etc.) are now collected with ~original exception as source when possible. These don't break the main process, unless `--stop-on-violation` is used, it was like that before too, but `ParallelisationException` was used for recreating error's source, which was not correct. - other errors (socket in/out errors caught by React, or unhandled errors that kill the worker) are re-thrown in the main process that effectively stop further execution
Configuration menu - View commit details
-
Copy full SHA for 0ad99f6 - Browse repository at this point
Copy the full SHA 0ad99f6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1bae68b - Browse repository at this point
Copy the full SHA 1bae68bView commit details