Repository navigation
Conversation
… Windows with PHP 8.5+ stream_select() on pipes takes a timer tick (about 15 ms) whenever nothing is ready, even with zero timeout, and it was called for each running job. More than 64 pipes in one call crash PHP. Now it is called once for all jobs, in chunks of 64.
… delay other tests for seconds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows with PHP 8.5+, two things are wrong with how Job reads output:
waitForActivity()passes the pipes of all running jobs to onestream_select(). With 65 or more pipes PHP 8.4, 8.5 and 8.6 end with 0xC0000409 (fixed in master by Fix stream_select() failing unpredictably (and crashing on Windows) with many descriptors php/php-src#14452), so-j 70kills the runner.isRunning()callsstream_select()with zero timeout for each job. If there is nothing to read, the call takes a timer tick, about 15 ms (stream_select() with a zero timeout sleeps on Windows when no pipe is ready php/php-src#25763), so with more jobs the output is read slowly.Now
stream_select()is called once for all jobs, in chunks of 64, andisRunning()reads 8 KB from those that are ready. A closed pipe is left out, because it would be always ready. Ifstream_select()fails, the job polls for itself as before.-j 1waits the same way. Other platforms and PHP < 8.5 are not changed.PHP 8.5.13, Windows 11,
-j 8, median of 10 runs:The "before" and "after" columns were measured in separate series on the same machine. The last two depend on the timer resolution: with a 1 ms timer, 8 × 4 MB takes about 0.5 s even before the change.
Known limits:
-j 1and-j 2gain less, because a call without result still takes a tick. That can be fixed only in PHP, see Fix GH-25763: stream_select() with a zero timeout sleeps on Windows php/php-src#25765.-j 16in 180 s. I could not reproduce it (0 of 40 runs, with this change 0 of 500), so I don't know the cause.Tests: the new ones pass on Windows 11 with PHP 8.5 and 8.6, NTS and ZTS, and are skipped where the code does not run. Without the change Job.select.phpt ends with a crash. All tests pass in the CI of my fork on Linux, macOS and Windows with PHP 8.1–8.6; on windows-latest with PHP 8.5.12 the new tests ran, not skipped. The new tests take about 20 s on Windows and 6 s on Linux. PHPStan fails as on master (DomQuery).