-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Don't read from the network faster than the CPU can deal with #35223
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
Conversation
@@ -113,7 +113,7 @@ public function request(string $method, string $url, array $options = []): Respo | |||
$url = implode('', $url); | |||
|
|||
if (!isset($options['normalized_headers']['user-agent'])) { | |||
$options['normalized_headers']['user-agent'][] = $options['headers'][] = 'User-Agent: Symfony HttpClient/Curl'; | |||
$options['headers'][] = 'User-Agent: Symfony HttpClient/Curl'; |
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.
is this change related to this gzip issue ?
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.
not directly (I spotted this was not required while working on the patch)
…PU can deal with (nicolas-grekas) This PR was merged into the 4.3 branch. Discussion ---------- [HttpClient] Don't read from the network faster than the CPU can deal with | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Something I spotted while working on #35115: both the curl and native clients don't play well with heavily compressed HTTP streams: they decompress faster than userland can process chunks. The attached patch moves the decompression logic to the chunk generator. This means internally we only deal with raw compressed chunks, and they are decompressed only when passing the value to userland. Commits ------- ac3d77a [HttpClient] Don't read from the network faster than the CPU can deal with
} | ||
|
||
if ('' !== $chunk && null !== $response->content && \strlen($chunk) !== fwrite($response->content, $chunk)) { | ||
$multi->handlesActivity[$j] = [null, new TransportException('Failed writing %d bytes to the response buffer.', \strlen($chunk))]; |
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.
@nicolas-grekas I think sprintf
is supposed to be here.
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.
correct :) would you mind sending a PR?
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.
Done #35250
This PR was submitted for the 5.4 branch but it was merged into the 6.3 branch instead. Discussion ---------- [HttpClient] Remove unused code | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Not needed since #35223 Commits ------- 5308c7c [HttpClient] Remove dead code
Something I spotted while working on #35115: both the curl and native clients don't play well with heavily compressed HTTP streams: they decompress faster than userland can process chunks.
The attached patch moves the decompression logic to the chunk generator. This means internally we only deal with raw compressed chunks, and they are decompressed only when passing the value to userland.