-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
Implement a max jobs per worker budget #4965
Conversation
will be AFK for a few hours |
@@ -59,7 +59,7 @@ public function disableParallel(): void | |||
SimpleParameterProvider::setParameter(Option::PARALLEL, false); | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reduced the jobsize, which leads to less memory used
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.
config/config.php
need to be updated as well:
Line 16 in 038f809
$rectorConfig->parallel(120, 16, 20); |
could you also update the different between $jobSize vs MAX_CHUNKS_PER_WORKER
? Thank you.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Looks good 👍
if ($jobs === []) { | ||
$this->processPool->quitProcess($processIdentifier); | ||
return; | ||
} | ||
|
||
$job = array_pop($jobs); | ||
$jobsChunk = array_pop($jobs); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is a bit ambiguous the different between $jobSize
vs MAX_CHUNKS_PER_WORKER
, could you write a comment here? Thank you.
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.
@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