-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Experimental run-tests.php parallelisation (2019 rebase) #3838
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
Experimental run-tests.php parallelisation (2019 rebase) #3838
Conversation
@nikic said this on the previous PR:
Basically, but the other way round. It implements parallelisation on the directory level — to be precise, tests from the same directory will by default not be run concurrently — but uses marker files to opt in a particular directory to parallelisation on the file level.
This would be possible. It would be a bit more annoying to implement, though, because the current parallelisation approach doesn't require reading any test files, it batches everything at the finding-files step. |
There's a significant bottleneck in the current code that becomes obvious when handling file tests, where the all the worker processes get bottlenecked by the supervisor process, probably because it's waiting on one particular worker process (to write to it?). This is probably easily fixed by me being less lazy and making the code more non-blocking. |
Programmer thinking. I assumed that |
Same here - better use another leading symbol than something similar to a not-symbol :-D However, very nice and thanks for the patch. |
$shameList | ||
----⚠️-----------------------------------------------------------⚠️---- | ||
|
||
NAME_AND_SHAME; |
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.
Have you ever heard of the heredoc indentation improvements in PHP 7.3?
Can you please add |
Ahaha, I understand now. I used |
To put the meta files ( Maybe just a side note/recap (and I really don't want to stop this essential and important missing feature in progress). I find the Anyhow, thank you for working on this. :) |
error("'$workers' is not a valid number of workers, try e.g. -j16 for 16 workers"); | ||
} | ||
$workers = intval($workers, 10); | ||
$environment['SKIP_IO_CAPTURE_TESTS'] = 1; |
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.
Why do we need to skip IO capture tests?
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.
The actual answer to this is “I wish I knew”. They behave completely incorrectly when parallelised testing is in use and for no obvious reason. I gave up trying to figure out why.
error("Could not find worker stdout in array of worker stdouts, THIS SHOULD NOT HAPPEN."); | ||
} | ||
while (FALSE !== ($rawMessage = fgets($workerSock))) { | ||
// work around fgets truncating things |
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.
Just double checked whether this is expected. From the stream_set_blocking
documentation:
If mode is FALSE, the given stream will be switched to non-blocking mode, and if TRUE, it will be switched to blocking mode. This affects calls like fgets() and fread() that read from the stream. In non-blocking mode an fgets() call will always return right away while in blocking mode it will wait for data to become available on the stream.
Which makes sense, of course a non-blocking socket can't just wait until a full line is received.
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.
Though this also makes me think that you shouldn't be just looping over fgets()
here. That should only be done if there's actually data available.
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.
That's what the stream_select
is supposed to be for, I guess.
echo $resultText; | ||
show_test($test_idx, "⚡️[" . count($workerProcs) . "/$workers concurrent test workers running]⚡️"); | ||
|
||
if (!is_array($name) && $result != 'REDIR') { |
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.
When does an array $name
happen?
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 think it was something to do with redirections, but I don't remember exactly.
@hikari-no-yume The number we are supposed to pass to nproc in Linux and
in macOS? |
@carusogabriel If that's what you'd pass to |
8319a3d
to
24d5931
Compare
I renamed |
24d5931
to
f93556a
Compare
I added -j2 to Travis and AppVeyor. Based on the commit history from October 2017, I think I previously determined -j4 wasn't worthwhile for those. |
Timings from CI runs: Travis: 905s -> 587s There are also some test failures. On Travis it's some tests using the built-in server. My guess would be that this is due to the assumption that all directories can be run in parallel, but here likely many directories contain tests using the built-in server and some probably have overlapping ports. On AppVeyor there are also some multi-byte filesystem tests failing, not sure if that can be related to the parallelization (some kind of environment difference?) |
While this functionality isn't perfect yet, and not stable enough for use in CI, it seems to be reliable for Zend tests (aka the only important tests!), so I went ahead and applied the first commit via 39792f5. We can implement further improvements based on this... |
Careful rebase and slight cleanup of #2822. It had this internals thread: http://news.php.net/php.internals/100838
The short and sweet summary is that if you have an 8-core 16-thread CPU and do
run-tests.php -j16
it will run… well, not quite 16x faster, but much closer to that than to the current speed. ^^Works on Windows and *nixen. Compatibility with all run-tests.php flags not guaranteed, but it's not on by default.