cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: http2: basic multiplexing seems to work now

From: Tatsuhiro Tsujikawa <tatsuhiro.t_at_gmail.com>
Date: Fri, 8 May 2015 16:31:37 +0900

Hi,

On Fri, May 8, 2015 at 12:36 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Thu, 7 May 2015, Tatsuhiro Tsujikawa wrote:
>
> ​I tried to make uploading work in multiplexed manner.
>>
>
> Cool, I haven't gotten around to that yet. I've tried going over the
> MAX_CONCURRENCY limit and I'm thinking of ways to handle that nicely...

​If you are thinking about using multiple connections if number of requests
are too large (e.g., 200), then it has to be done manually.​
Otherwise, ​nghttp2 enforces server's MAX_CONCURRENT_STREAMS internally.
If more than MAX_CONCURENT_STREAMS handles are added, and
"nghttp2_submit_request" called, nghttp2 waits for some streams finish, and
then issue the remaining ones.
HTTP/2 specification does not impose the initial value of
MAX_CONCURRENT_STREAMS, so it is effectively unlimited, so nghttp2 does.
But nghttp2 has an API "nghttp2_option_set_peer_max_concurrent_streams",
which can set maximum concurrent streams as if it is received from peer,
and it is updated when SETTINGS are actually received from peer. So
libcurl could use it to start smaller value (1 is safest way, but could be
too conservative), and then let nghttp2 update it.

>
>
> Well it partially worked actually. The thing is 2 uploads did not happen
>> simultaneously, instead it happened sequentially. I guess that pipelining
>> code may serialize uploading as a part of request, but I have not checked
>> it yet.
>>
>
> I'm pretty sure that's a correct suspicion. I just pushed one change that
> may affect it in a positive direction but I'm sure there are some more
> details like that left to fix.
>
>
​Thanks. I saw that commit.
While I was hacking around libcurl stuff, it seems that
"IsPipeLiningPossible" is called before we set conn->httpversion = 20, so
it just returns FALSE if we use PUT method.​

> Another issue is upload speed is very slow. It seems like it uploads one
>> DATA frame per second. Probably, current code does not check that socket is
>> writable?
>>
>
> Yeah, I think it may suffer from a similar issue that I ran into for
> download: when many streams share the same socket we need to go through
> several handles to send data for which the current code really never have
> done.
>
>
​It seems so. In my branch, I managed to make libcurl check socket to use
do some tricks. It works with single upload, bu​t I really don't know it
also works when multiple uploads are done inside one connection. Will see.

> I'll share my code later.
>>
>
> Excellent!
>
>
​Here is my http2-upload branch:
https://github.com/tatsuhiro-t/curl/tree/http2-upload

Currently, it can upload, but serially, due to ​"IsPipeLiningPossible"
returns FALSE as described above.
I just hack it to return TRUE to make sure it really works otherwise, but
then I found that transfer stalls if I make 2 streams upload simultaneously.
It seems that libcurl only reads same file descriptor for 2 streams
(conn->fread_in in "Curl_fillreadbuffer" returns same pointer). I could be
wrong.
Still needs more investigation.

Best regards,
Tatsuhiro Tsujikawa

> PS: I submitted PR on github to fix several issues I encountered while
>> playing around multiplex branch.
>> https://github.com/bagder/curl/pull/260
>>
>
> I noticed. Thanks a bunch, I'll merge those as soon as possible!
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-05-08