New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 705551 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Feature



Sign in to add a comment

HTTP/2 code sends five frames in a row in separate packets

Project Member Reported by davidben@chromium.org, Mar 27 2017

Issue description

svaldez and I were looking at packet traces of our h2 code earlier (the original motivation was seeing what it'd take to pack the ClientHello into the same packet in TLS 1.3 0-RTT) and noticed we're not very efficient about starting h2 connections. It probably got even worse going from SPDY to HTTP/2 because of the silly magic string at the front.

It appears, when starting an h2 connection, we send:

Magic
SETTINGS
WINDOW_UPDATE
SETTINGS
HEADERS

all in row, but in four separate packets and TLS records. That means unnecessary TLS overhead (each record adds a fixed amount of overhead) and also more sensitivity to packet loss. These frames would very comfortably fit in a single packet.

bnc, could you look into this? The SSLKEYLOGFILE feature may be useful if you want to decrypt the SSL records. Or you could look at net-internals.
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format
 
Summary: HTTP/2 code sends five frames in a row in separate packets (was: HTTP/2 code sends four frames in a row in separate packets)
I can't count.

Comment 2 by b...@chromium.org, May 26 2017

Status: Started (was: Assigned)
Serializing HTTP/2 preface, optional initial SETTINGS, and optional initial WINDOW_UPDATE happens in one go within SpdySession, so combining them is straightforward.

Slapping on the SETTINGS ACK is tricky: this is only send after a SETTINGS frame is received from the server.  Shall we wait for that?  What if initial request could be sent out earlier?  What if both peers wait for to receive the other's SETTINGS frame before they send out their own so that they can combine it with the SETTINGS ACK, resulting in a lock?

As for the HEADERS, that would make sense, but would be fairly complicated: HttpStreamFactoryImpl::Job calls into SpdySessionPool which instantiates SpdySession and initializes the connection, but then it notifies JobController which in turn notifies HttpNetworkTransacion which then initiates the stream with the request.  I am not even sure this happens synchronously.  Maybe one could withhold enqueueing any data in SpdySession until the first set of HEADERS is ready to be sent out.

Comment 3 by b...@chromium.org, May 26 2017

Of course I misspoke (miswrote?): initial SETTINGS frame is not optional (though it may be empty).
Well, two or three packets is still better than five. :-)
Project Member

Comment 5 by bugdroid1@chromium.org, Jun 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8abf64aff97080b772d924ebf79d4c74d14eea0d

commit 8abf64aff97080b772d924ebf79d4c74d14eea0d
Author: bnc <bnc@chromium.org>
Date: Wed Jun 07 20:18:54 2017

SpdySession: Combine three frames into a single packet.

Combine HTTP/2 connection preface, initial SETTINGS frame, and optional
initial WINDOW_UPDATE frame into a single SpdySerializedFrame so that it
can be send on the wire in a single packet.

Also combine said frames in tests.  (Because of the way expected and
actual write data are compared, tests expecting individual packets
(before this change) pass with the packets sent separately or combined,
but tests expecting combined packets (after this change) only pass
when packets are actually combined.)

BUG=705551

Review-Url: https://codereview.chromium.org/2909653002
Cr-Commit-Position: refs/heads/master@{#477745}

[modify] https://crrev.com/8abf64aff97080b772d924ebf79d4c74d14eea0d/net/spdy/chromium/spdy_network_transaction_unittest.cc
[modify] https://crrev.com/8abf64aff97080b772d924ebf79d4c74d14eea0d/net/spdy/chromium/spdy_session.cc
[modify] https://crrev.com/8abf64aff97080b772d924ebf79d4c74d14eea0d/net/spdy/chromium/spdy_session.h
[modify] https://crrev.com/8abf64aff97080b772d924ebf79d4c74d14eea0d/net/spdy/chromium/spdy_session_unittest.cc

Comment 6 by b...@chromium.org, Jun 8 2017

Cc: b...@chromium.org
Labels: -Type-Bug Type-Feature
Owner: ----
Status: Available (was: Started)
I decreased the number of packets from five to three by combining the first three of them into one.  This is already an improvement as stated in comment #4.  The acknowledgement SETTINGS frame should not be combined for reasons laid out in comment #2.  Combining the HEADERS frame is theoretically possible, but currently not high on my list, so I am making this issue Available if someone wants to grab it.
Thanks, Bence!
Project Member

Comment 8 by sheriffbot@chromium.org, Jun 8 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Available (was: Untriaged)
It's a low priority optimization. Leaving it at Available seems reasonable.

Sign in to add a comment