Skip to content

Commit

Permalink
bug #11120 [2.3][Process] Reduce I/O load on Windows platform (romain…
Browse files Browse the repository at this point in the history
…neutron)

This PR was merged into the 2.3 branch.

Discussion
----------

[2.3][Process] Reduce I/O load on Windows platform

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT

When using file handles, no `stream_select` call is done.
On linux platforms, `stream_select` introduce a sleep as it has 0.2s timeout, there is no such pause on Windows, producing lot's of disk I/Os when reading file handles

Commits
-------

ff0bb01 [Process] Reduce I/O load on Windows platform
  • Loading branch information
fabpot committed Jul 23, 2014
2 parents 797d814 + ff0bb01 commit 4dbe0e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Symfony/Component/Process/ProcessPipes.php
Expand Up @@ -284,6 +284,8 @@ private function readFileHandles($close = false)
private function readStreams($blocking, $close = false)
{
if (empty($this->pipes)) {
usleep(Process::TIMEOUT_PRECISION * 1E4);

return array();
}

Expand Down
9 changes: 8 additions & 1 deletion src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Expand Up @@ -596,7 +596,14 @@ public function testRunProcessWithTimeout()
}
$duration = microtime(true) - $start;

$this->assertLessThan($timeout + Process::TIMEOUT_PRECISION, $duration);
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
// Windows is a bit slower as it read file handles, then allow twice the precision
$maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION;
} else {
$maxDuration = $timeout + Process::TIMEOUT_PRECISION;
}

$this->assertLessThan($maxDuration, $duration);
}

public function testCheckTimeoutOnNonStartedProcess()
Expand Down

0 comments on commit 4dbe0e1

Please sign in to comment.