-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
curl consumes 100% CPU when sending a file with -F #11242
Comments
Does this by any chance use HTTP/2 when uploading? (if you add Oops. sorry yes it does. The nghttp2_* symbols indicate that. |
@icing when you have a minute over, can you have a look at this? |
- related to curl#11242 where curl enters busy loop when sending http2 data to the server
On Sun, Jun 04, 2023 at 03:46:30AM -0700, Stefan Eissing wrote:
@l29ah would you be able to try #11247 in your setup? I made the code that sends the http2 data up more robust in handling EAGAIN situations.
Tried slapping it on top of 8.1.2, still 100% CPU.
…--
() ascii ribbon campaign - against html mail
/\ http://arc.pasp.de/ - against proprietary attachments
|
Could you make a build with
Thank you! |
I cannot reproduce. I tried sending a fairly large file to that same server using this curl version:
|
https://tinystash.undef.im/il/2EQtfhvYcr9r9SPd1TkCyqudqFDNKSc9yaCHNAw9t4gsEdd9gKLaQUKAt2pBMiTgKow7kDcA2DhETsB8Q2ggAWsw |
In the log I see that the upload is progressing. So we have no stall or busy loop here, "just" the action of chunking your upload file into the 16KB frame data of the HTTP/2 protocol, encrypting those and passing them to the network. I, so far, see nothing wrong, except that the implementation is not as efficient as you would like it to be. |
Downgraded curl to 8.0.1, now it consumes <1% CPU on the same scenario. |
Reproduced. You convinced me that this does not look right. Analyzing what I did here... |
- refs curl#11242 where abnormal CPU on uploads wa reported - this is mainly due to the drain dselect_bits being set during uploads where they should not. This was continually EXPIRing the transfer - BUT toying with large uplaods on my connection against the server in the issue revealed a deeper problem with buffer handling that leads to failed uploads Outline: - when curl is faster than the TCP connection, we get EAGAIN in various stages of uploads - Then, data is left pending in buffers a) the stream->sendbuf b) the filters ctx->outbufq c) nghttp2 itself - Problem a) I addressed in this branch - Problem b) could be solved, however - Problem c) is the real issue nghttp2 hold internally the DATA frame it has collected from out callbacks, but it is not able to write it to the network due to EAGAIN. It try to write it on next opportunity. Fine. But when is that opportunity? Well, if an upload EAGAINs on the very last DATA frame, transfer.c declares it is done and never calls send again. The transfer times out and is reset by the server.
- refs curl#11242 where CPU busy loop is reported. Removed drain setting that caused this - discovered stalled uploads using the server from curl#11242 on my slow internet - added workaround on flushing the last upload chunk that, if not written fully, makes the transfer stall. This is not the fix we are looking for.
Ok, if your find the time, you could give #11342 a try on your setup. This is a fix for the CPU and for stalled uploads that I observed here. Likelihood of those depend on network conditions. We are discussing how best to resolve that one. But it would be good to know if this PR makes the upload work flawlessly for you. updated to the new PR |
- refs curl#11242 where abnormal CPU on uploads wa reported - this is mainly due to the drain dselect_bits being set during uploads where they should not. This was continually EXPIRing the transfer - BUT toying with large uplaods on my connection against the server in the issue revealed a deeper problem with buffer handling that leads to failed uploads Outline: - when curl is faster than the TCP connection, we get EAGAIN in various stages of uploads - Then, data is left pending in buffers a) the stream->sendbuf b) the filters ctx->outbufq c) nghttp2 itself - Problem a) I addressed in this branch - Problem b) could be solved, however - Problem c) is the real issue nghttp2 hold internally the DATA frame it has collected from out callbacks, but it is not able to write it to the network due to EAGAIN. It try to write it on next opportunity. Fine. But when is that opportunity? Well, if an upload EAGAINs on the very last DATA frame, transfer.c declares it is done and never calls send again. The transfer times out and is reset by the server.
- refs curl#11242 where CPU busy loop is reported. Removed drain setting that caused this - discovered stalled uploads using the server from curl#11242 on my slow internet - added workaround on flushing the last upload chunk that, if not written fully, makes the transfer stall. This is not the fix we are looking for.
- fixes curl#11242 where 100% CPU on uploads was reported - fixes possible stalls on last part of a request body when that information could not be fully send on the connection due to an EAGAIN - applies the same EGAIN handling to HTTP/2 proxying
- fixes curl#11242 where 100% CPU on uploads was reported - fixes possible stalls on last part of a request body when that information could not be fully send on the connection due to an EAGAIN - applies the same EGAIN handling to HTTP/2 proxying
- related to curl#11242 where curl enters busy loop when sending http2 data to the server Closes curl#11247
- fixes curl#11242 where 100% CPU on uploads was reported - fixes possible stalls on last part of a request body when that information could not be fully send on the connection due to an EAGAIN - applies the same EGAIN handling to HTTP/2 proxying Reported-by: Sergey Alirzaev Fixed curl#11242 Closes curl#11342
- related to curl#11242 where curl enters busy loop when sending http2 data to the server Closes curl#11247
- fixes curl#11242 where 100% CPU on uploads was reported - fixes possible stalls on last part of a request body when that information could not be fully send on the connection due to an EAGAIN - applies the same EGAIN handling to HTTP/2 proxying Reported-by: Sergey Alirzaev Fixed curl#11242 Closes curl#11342
I did this
curl -Ffile=@"VID_20230603_010956.mp4" https://0x0.st
I expected the following
Tiny CPU consumption appropriate for the pathetic ~200kB/s transfer speed on my i7 CPU.
curl/libcurl version
operating system
Gentoo Lignux
Linux l29ah-x201 6.2.5+ #238 SMP PREEMPT_DYNAMIC Mon Mar 13 02:40:28 CET 2023 x86_64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz GenuineIntel GNU/Linux
top of perf report
The text was updated successfully, but these errors were encountered: