Skip to content

[Parallel] Terminate timed out and unconnected workers - #8522

Merged
TomasVotruba merged 1 commit into
rectorphp:mainfrom
janwaleed09:fix/parallel-worker-termination
Sep 30, 2026
Merged

TomasVotruba merged 1 commit into
rectorphp:mainfrom
janwaleed09:fix/parallel-worker-termination

Conversation

@janwaleed09

Copy link
Copy Markdown
Contributor

When a worker gets stuck, e.g. in an endless loop, the timeout is reported, but Rector never ends: quit() only closes the connection, and a stuck worker never reads it. A worker that is still starting when the run is aborted has no connection at all. The main process waits for both forever (see rectorphp/rector#7711).

@TomasVotruba
TomasVotruba force-pushed the fix/parallel-worker-termination branch from 37251f5 to 54ce386 Compare September 30, 2026 13:02
@TomasVotruba
TomasVotruba merged commit 5b56397 into rectorphp:main Sep 30, 2026
50 checks passed
@TomasVotruba

Copy link
Copy Markdown
Member

Thank you 👍

This is pretty complex, how did you figure it out?

@janwaleed09

Copy link
Copy Markdown
Contributor Author

Thank you 👍

This is pretty complex, how did you figure it out?

Thanks for merging both!

It started at work: we updated Rector on a large project and I wanted to understand the parallel run better. I read ParallelFileProcessor and ParallelProcess, compared them with PHPStan's Process.php, and found #7711, which describes exactly this hang.

To reproduce it, I used a worker that never answers (just sleep) and aborted the run. Rector waited forever, on macOS and on Linux. On Linux there was one more catch: the worker runs in sh -c, and dash doesn't replace itself with PHP, so terminating only killed the shell. The ReactPHP docs suggest exec for that.

@TomasVotruba

TomasVotruba commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Cool 👍

Btw, how many loc your project has and how long does it take to perform one Rector run?

@janwaleed09

Copy link
Copy Markdown
Contributor Author

Around 4,400 PHP files and 470k lines.

A full run with a cold cache takes about 80 seconds on an M1 Max (10 cores, 6 parallel processes) with 700-850 MB per worker. With a warm cache and only a few changed files it takes 1-2 seconds.

@TomasVotruba

Copy link
Copy Markdown
Member

I see. Not bad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants