Implement a max jobs per worker budget#4965
Conversation
|
will be AFK for a few hours |
| } | ||
|
|
||
| public function parallel(int $seconds = 120, int $maxNumberOfProcess = 16, int $jobSize = 20): void | ||
| public function parallel(int $seconds = 120, int $maxNumberOfProcess = 16, int $jobSize = 15): void |
There was a problem hiding this comment.
reduced the jobsize, which leads to less memory used
There was a problem hiding this comment.
config/config.php need to be updated as well:
Line 16 in 038f809
could you also update the different between $jobSize vs MAX_CHUNKS_PER_WORKER ? Thank you.
There was a problem hiding this comment.
I dropped the args in this file, as these just reflect the defaults and therefore don't need to be kept in sync
could you also update the different between $jobSize vs MAX_CHUNKS_PER_WORKER ?
where?
There was a problem hiding this comment.
| } | ||
|
|
||
| $job = array_pop($jobs); | ||
| $jobsChunk = array_pop($jobs); |
There was a problem hiding this comment.
renaming because the previous name suggested it would be a single job
|
with the parameter adjustments at this point we can run rector across mautic with with a peak of 14.75 GB. it never grows higher then that: with rector 0.18.2 it peaks at 16.5 GB RAM and takes => with this PR (and all the already merged optimizations) we are 20 seconds faster and take ~1.75 GB less memory |
| * | ||
| * @var int | ||
| */ | ||
| private const MAX_CHUNKS_PER_WORKER = 8; |
There was a problem hiding this comment.
it is a bit ambiguous the different between $jobSize vs MAX_CHUNKS_PER_WORKER, could you write a comment here? Thank you.
samsonasik
left a comment
There was a problem hiding this comment.
@TomasVotruba let's quick merge and revert in case of it doesn't work :)
Thank you @staabm
|
@staabm I am testing in CodeIgniter 4 project, when we define: $rectorConfig->parallel(240, 8, 1);the procss got 2 times slower, but when we define default value: $rectorConfig->parallel();the performance seems equals, I mention you in PR test at: so in case other CodeIgniter4 project maintainer has different use case, they can give you feedback faster :) |
thats expected. the smaller the jobsize is and the smaller the chunks-per-worker is, the slower the rector job will get. the higher the jobsize and the higher the chunks-per-worker are, rector gets faster but requires more memory. its a balance between memory and speed. before this PR all default settings were set for maximum speed but without limits for memory. thats the actual problem the bigger the project gets we analyze. with this PR we have a mean to cut the memory peaks. performance and memory also depends whether rector just scans the codebase and does not need todo anything or whether it needs to refactor something |
|
@Flyingmana @yguedidi you might be interessted in testing rector@dev-main which now uses process re-spawning to recover from memory leaks and memory spikes |
implements rectorphp/rector#8192