Skip to content
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

re-spawn worker processes #8192

Closed
staabm opened this issue Sep 10, 2023 · 2 comments
Closed

re-spawn worker processes #8192

staabm opened this issue Sep 10, 2023 · 2 comments
Labels

Comments

@staabm
Copy link
Contributor

staabm commented Sep 10, 2023

Memory optimization oportunity

watching rector in e.g. htop while running on a big project (e.g. mautic) we can easily see that most of the memory used is within the worker processes

grafik

these processes start small and grow over time. the more files a worker has processed, the more memory it hogs.
since we disabled the garbage collector the memory is all time growing.

this means in the end of the analysis the workers contain a lot of allocated memory, which leaked from all the files on their way thru the codebase, which was never freed because no GC.

since we disabled the GC intentionally to improve performance, I think we should limit the number of files a worker processes.
if a worker would die after X amount of files and a new worker would be spawned (so the overall number of workers would still be stable), we would free the memory and rector would need less memory.

I had a look into the codebase but could not find the right parts to implement the idea.
parallel stuff is a bit distributed across classes which made it hard for me to start.

maybe @TomasVotruba or @samsonasik have a better idea of the parallel infrastrutcture, so we could e.g. limit each workers files to be processed to e.g. 10x the job-size or similar. wdyt?

@staabm staabm added the bug label Sep 10, 2023
@samsonasik
Copy link
Member

There was an effort by @Flyingmana at PR:

but cause some process forced terminated before actually complete, so that was reverted at:

@samsonasik
Copy link
Member

Resolved at rectorphp/rector-src#4965

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants