Re: Identify streams unidirectional vs bidirectional based on stream ID

Martin Thomson <martin.thomson@gmail.com> Fri, 27 October 2017 04:55 UTC

Return-Path: <martin.thomson@gmail.com>
X-Original-To: quic@ietfa.amsl.com
Delivered-To: quic@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B1BF11389BC for <quic@ietfa.amsl.com>; Thu, 26 Oct 2017 21:55:26 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.7
X-Spam-Level:
X-Spam-Status: No, score=-2.7 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a_mGR55BwCmZ for <quic@ietfa.amsl.com>; Thu, 26 Oct 2017 21:55:24 -0700 (PDT)
Received: from mail-oi0-x22a.google.com (mail-oi0-x22a.google.com [IPv6:2607:f8b0:4003:c06::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 16559137C4A for <quic@ietf.org>; Thu, 26 Oct 2017 21:55:24 -0700 (PDT)
Received: by mail-oi0-x22a.google.com with SMTP id j126so9180070oib.8 for <quic@ietf.org>; Thu, 26 Oct 2017 21:55:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=lEi5rwlpWzSftjzg43h0pEuexBB1KPxYR4FqkVJt7og=; b=k8xSrOjk/6JwwI2NtBpsdyY0fauaqwyDFafH7GG7OW5SGTLXbtntdVvjkXiCBZ3V0s uSQLlgcAVMcOndEeH8/G242cprc1fWBn66a1GOC77cRNz4oSApzhGv0zAnikeKUyb/CS 6LumdFgbChrOxSJ4Q/EB0i1Hqm7AYIsy8B62hgrNUxhPSkPr5f5Qa90zYPJXXtEfghFe 8l0+u/z/UmjDjO2tYIbIX4WmOpD9yUQC6d8OZhDhXPV1W9OlW89UAq0o7iCLNQ3d0FQ6 9KW5GlwiAPqSr/mseKKzku7i9z7+cLnfYXlqythXFjzfmMBP4PbO7I62zFlwLyQHPH4e dASA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=lEi5rwlpWzSftjzg43h0pEuexBB1KPxYR4FqkVJt7og=; b=bQDVTQteGtDOrFvcZlOSPPNXqoxmkOtbkvso7s2qMupAfidloihNVTgRIQpuzC9uHi WY+RbG4dEcU407ZVSwZEeLx2bCUA/SAjG8CBIqltRwOGE0BICReWK/2p90KyJ4yR18+x rvROp7yxOKwfMCt5e5gLeA6aqlypcn/qGWDB8Y1Dfpv8YAlkBo2ZHp4Z6bSo+eJJme3D xD96JGGqXXVgugleO3LSpu9kZmzPfNys6AnFjSfIaiXzTa1CLTF76eEDkNP+oBcLQgea 4NcHDaIYPpIXenNpLeST+zu6DavnflE2Ulp40B73ooXSvfK3ic+hnAcBhjgKnoVo7wyp KHQQ==
X-Gm-Message-State: AMCzsaUStj+pbgIMYt6/UJ6RbDzVNoIuh662l3yAEl936NMILlxSWDlg Epo7cTiZwFjfzWBwoy6MH5RuYwCsbPHxEWBD1Jl9ag==
X-Google-Smtp-Source: ABhQp+QhdT59mSe7daC+iYE2E+ZwattYpi2NYI6pnvbe603s/h1PkAiu4x55AAC1kI+8LW4c7yrlZN/bKfKJuLenVi8=
X-Received: by 10.157.53.17 with SMTP id o17mr2566856otc.35.1509080123209; Thu, 26 Oct 2017 21:55:23 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.72.178 with HTTP; Thu, 26 Oct 2017 21:55:22 -0700 (PDT)
In-Reply-To: <CAGD1bZapVjFsyi-SwhzzG5c3-gD+c9wWKTAuKRBP7iQL_DTHXQ@mail.gmail.com>
References: <CAJ_4DfQe=twhj3OBy1o6h+u1O4qB2YzD26EMCHKnz4HWEEa7OQ@mail.gmail.com> <0ffd80fd-d6a9-5df4-2128-d304b65dedf4@in.tum.de> <CAN1APdcT7djsTTt8fxx8S7cY1_7Tp-mhxedk-nnzyF2+XV6+GQ@mail.gmail.com> <MWHPR21MB01412840605BA9EBC872900D87480@MWHPR21MB0141.namprd21.prod.outlook.com> <CAKcm_gPFF=j68F4Ehrg__m2sWi-wdKRSnjqv8MxnSNyEVZSUUA@mail.gmail.com> <DC15026F-2376-41B3-B05E-C5606C8E0C73@fb.com> <CAKcm_gN=qer1VCG2KS8oLhsfa15A3Jg0ghxhssiVn9qyHP-2Tw@mail.gmail.com> <CAGD1bZbnGAmAewnxjqJqhUnz8n47=+5pg3UwdHW1Y5=DdHYHtA@mail.gmail.com> <CABkgnnUYH_aqkUR=aS9HWj4-=7KNz=OS3jpPtwQdz+jqQ+nKPg@mail.gmail.com> <CAN1APdfesrEFGajX6OajjtL9vBd2Bu19RM7WW3cp+35de=R34g@mail.gmail.com> <MWHPR21MB0288008D1302D533FB07C6DFB64C0@MWHPR21MB0288.namprd21.prod.outlook.com> <CAGD1bZYP23okSyWvkQ5jjbCPkciYLk2Bs_zkpqJDYOpS99R9XQ@mail.gmail.com> <CAGD1bZapVjFsyi-SwhzzG5c3-gD+c9wWKTAuKRBP7iQL_DTHXQ@mail.gmail.com>
From: Martin Thomson <martin.thomson@gmail.com>
Date: Fri, 27 Oct 2017 15:55:22 +1100
Message-ID: <CABkgnnVuSY9CFyF2C0PNSd00g3CJ2OJDFPMhy=MESBk_2MujMA@mail.gmail.com>
Subject: Re: Identify streams unidirectional vs bidirectional based on stream ID
To: Jana Iyengar <jri@google.com>
Cc: Praveen Balasubramanian <pravb@microsoft.com>, Mikkel Fahnøe Jørgensen <mikkelfj@gmail.com>, Mike Bishop <Michael.Bishop@microsoft.com>, Ian Swett <ianswett@google.com>, "quic@ietf.org" <quic@ietf.org>, Hugues Fafard <fafard@in.tum.de>, Roberto Peon <fenix@fb.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/quic/H8mcAvkIxgdhwKqV4Rirbdc4D7c>
X-BeenThere: quic@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Main mailing list of the IETF QUIC working group <quic.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/quic>, <mailto:quic-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/quic/>
List-Post: <mailto:quic@ietf.org>
List-Help: <mailto:quic-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/quic>, <mailto:quic-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 27 Oct 2017 04:55:27 -0000

Please note that #885 is the same patch with additional changes.  #872
has bugs with stream identifiers that #885 corrects.  (#885 also says
what a unidirectional and bidirectional stream is more clearly.)

On Fri, Oct 27, 2017 at 6:42 AM, Jana Iyengar <jri@google.com> wrote:
> I'd like to merge #872. If I don't hear any serious issues I'll merge it
> tomorrow.
>
> On Mon, Oct 16, 2017 at 11:56 PM, Jana Iyengar <jri@google.com> wrote:
>>
>> On Mon, Oct 16, 2017 at 6:41 PM, Praveen Balasubramanian
>> <pravb@microsoft.com> wrote:
>>>
>>> I agree that this is adding complexity with four special cases, but I
>>> would actually argue the other way: apps that want uni streams should be
>>> able to use the existing bidi stream mechanism. An API for uni stream can
>>> achieve this by closing the stream in one direction immediately after
>>> opening it so that the very first packet for that stream signals that one
>>> direction is closed and the other end knows that the stream is uni. Bidi
>>> streams are a more general case and if we are going to support them (which I
>>> think we should) then do we need any dedicated transport mechanisms for uni
>>> streams?
>>
>>
>> There's not a lot of dedicated mechanisms; indeed you can implement uni as
>> a special case of bidi streams. The issue was, as Ian summarized nicely
>> here, that implicitly open streams became ambiguous. For instance if stream
>> 15 was opened after stream 11,  the spec requires stream 13 to be opened
>> implicitly, but should it be opened as a uni stream or a bidi one?
>> Separating namespaces for uni/bidi means that only streams in that
>> particular namespace are opened implicitly.
>>
>>
>>>
>>>
>>>
>>> Thanks
>>>
>>>
>>>
>>> From: QUIC [mailto:quic-bounces@ietf.org] On Behalf Of Mikkel Fahnøe
>>> Jørgensen
>>> Sent: Monday, October 16, 2017 6:20 PM
>>> To: Martin Thomson <martin.thomson@gmail.com>; Jana Iyengar
>>> <jri@google.com>
>>> Cc: Mike Bishop <Michael.Bishop@microsoft.com>; Ian Swett
>>> <ianswett@google.com>; quic@ietf.org; Hugues Fafard <fafard@in.tum.de>;
>>> Roberto Peon <fenix@fb.com>
>>>
>>>
>>> Subject: Re: Identify streams unidirectional vs bidirectional based on
>>> stream ID
>>>
>>>
>>>
>>> I’m just wondering why this approach was preferred as opposed to building
>>> bidi on top of uni. I suppose this must have been discussed at the interim
>>> and in part based on the recent experimental implementation of uni streams.
>>>
>>>
>>>
>>> A straightforward implementation may not have much difficulty in handling
>>> the implementation either way but when you attempt to achieve low latency
>>> and low memory foot print with shortest possible state life times including
>>> coordination with application level buffers, then bidi streams are not very
>>> fun to work with at the transport level. As become more agreeable after it
>>> was concluded that teardown did not have to wait for FIN ACK and related,
>>> but it is still a lot of complexity with potential bugs.
>>>
>>>
>>>
>>> One aspect of the complexity is that there are now four special cases
>>> instead of two in the stream identifiers which must be dealt with in several
>>> frame types. Some of this involves flow control per stream type which bidi
>>> on top of uni would not support at the same granularity, but is this really
>>> needed?
>>>
>>>
>>>
>>> Adding uni streams in addition to bidi streams is still a lot better than
>>> not having uni streams because they solve problems such as async messaging
>>> at high volume and partial reliability via throw away streams. However, they
>>> do nothing to simplify the transport with the current proposal.
>>>
>>>
>>>
>>> Kind Regards,
>>>
>>> Mikkel Fahnøe Jørgensen
>>>
>>>
>>>
>>> On 17 October 2017 at 02.49.38, Martin Thomson (martin.thomson@gmail.com)
>>> wrote:
>>>
>>> Those low order bits are important. No need to rush (it's a
>>> relatively small changeset).
>>>
>>> On Tue, Oct 17, 2017 at 10:48 AM, Jana Iyengar <jri@google.com> wrote:
>>> > Based on what I'm seeing on the PR and on this thread, I think there's
>>> > general agreement on this strategy to go forward. I would like to merge
>>> > this
>>> > PR soon, modulo a new revision to address some open comments. (There's
>>> > currently a question about whether to use the high or the low-order
>>> > bits for
>>> > this, which should also get resolved before merging.)
>>> >
>>> > I'm asking folks to please review and speak up if they have
>>> > disagreements
>>> > with the direction or with any specifics.
>>> >
>>> > I'll be away from connectivity for a week, so unless there are
>>> > unresolved
>>> > issues then, I'd like to merge this in a week when I return. Martin can
>>> > merge this sooner if there's only agreement.
>>> >
>>> > On Mon, Oct 16, 2017 at 8:15 AM, Ian Swett <ianswett@google.com> wrote:
>>> >>
>>> >> I believe the motivation for separate stream limits is to put a
>>> >> reasonable
>>> >> limit on the number of incoming streams you'll accept. Otherwise, an
>>> >> application could use a very large number of one type(ie: uni) of
>>> >> stream and
>>> >> almost none of another(ie: bidi), which would allow them to suddenly
>>> >> open a
>>> >> huge number of the other type(ie: bidi) of stream if they wanted.
>>> >>
>>> >> If we were using H2 style max open streams we could do it either way,
>>> >> but
>>> >> I think keeping them separate is probably best anyway.
>>> >>
>>> >> On Mon, Oct 16, 2017 at 11:01 AM, Roberto Peon <fenix@fb.com> wrote:
>>> >>>
>>> >>> In H2, the even/odd thing was just an easy way to encode a unique ID
>>> >>> per
>>> >>> stream while indicating direction.
>>> >>> This proposal seems to do the same thing, and that makes sense to
>>> >>> me—instead of even-odd, we have mod-4-offset.
>>> >>>
>>> >>> I’d ask why bother to have separate stream limits. You could still
>>> >>> just
>>> >>> have the one limit for the overall space.
>>> >>> With H2, that was part of the point of putting it there (though it
>>> >>> was
>>> >>> implit)—it was all part of one space, and thus the space was singly
>>> >>> countable!
>>> >>>
>>> >>>
>>> >>>
>>> >>> -=R
>>> >>>
>>> >>>
>>> >>>
>>> >>> From: QUIC <quic-bounces@ietf.org> on behalf of Ian Swett
>>> >>> <ianswett@google.com>
>>> >>> Date: Friday, October 13, 2017 at 2:05 PM
>>> >>> To: Mike Bishop <Michael.Bishop@microsoft.com>
>>> >>> Cc: Mikkel Fahnøe Jørgensen <mikkelfj@gmail.com>, "quic@ietf.org"
>>> >>> <quic@ietf.org>, Hugues Fafard <fafard@in.tum.de>
>>> >>>
>>> >>>
>>> >>> Subject: Re: Identify streams unidirectional vs bidirectional based
>>> >>> on
>>> >>> stream ID
>>> >>>
>>> >>>
>>> >>>
>>> >>> In many ways, they are 4 independent spaces, but Ryan pointed out to
>>> >>> me
>>> >>> that both for the purposes of draft text and implementation it's very
>>> >>> useful
>>> >>> to have a single unique identifier for a stream, since otherwise you
>>> >>> have to
>>> >>> talk about/pass around (StreamID, Type) everywhere instead of just
>>> >>> StreamID.
>>> >>>
>>> >>>
>>> >>>
>>> >>> Keeping one stream ID avoids creating two of all the stream specific
>>> >>> frames(STOP_SENDING, RST_STREAM, STREAM_FRAME, MAX_DATA_OFFSET, etc),
>>> >>> one
>>> >>> for each stream space.
>>> >>>
>>> >>>
>>> >>>
>>> >>> Using the two most significant bits would eliminate the usefulness of
>>> >>> any
>>> >>> variable length integer encoding(current or Martin's new proposal),
>>> >>> so using
>>> >>> the lower bits makes sense.
>>> >>>
>>> >>>
>>> >>>
>>> >>> On Fri, Oct 13, 2017 at 4:56 PM, Mike Bishop
>>> >>> <Michael.Bishop@microsoft.com> wrote:
>>> >>>
>>> >>> Indeed. I almost think it makes more sense to say that there are four
>>> >>> independent stream spaces, each with their own numbers. That does
>>> >>> mean that
>>> >>> each side will need to separately manage Max Stream ID for two
>>> >>> spaces, but
>>> >>> that seems more reasonable than the alternative. In fact, this PR
>>> >>> already
>>> >>> implies that the limits for unidirectional and bidirectional streams
>>> >>> are
>>> >>> handled separately, which gets really weird when the IDs are
>>> >>> interleaved
>>> >>> with each other.
>>> >>>
>>> >>>
>>> >>>
>>> >>> In fact, this plays well with the variable-length encoding idea,
>>> >>> since
>>> >>> the maximum size of a Stream ID would be 62 bits. They could then be
>>> >>> stored
>>> >>> locally as a 64-bit value with the “extra” bits indicating which
>>> >>> space they
>>> >>> refer to.
>>> >>>
>>> >>>
>>> >>>
>>> >>> From: QUIC [mailto:quic-bounces@ietf.org] On Behalf Of Mikkel Fahnøe
>>> >>> Jørgensen
>>> >>> Sent: Friday, October 13, 2017 1:04 PM
>>> >>> To: quic@ietf.org; Hugues Fafard <fafard@in.tum.de>
>>> >>> Subject: Re: Identify streams unidirectional vs bidirectional based
>>> >>> on
>>> >>> stream ID
>>> >>>
>>> >>>
>>> >>>
>>> >>> Especially with the new variable length encoding proposal, storing
>>> >>> the
>>> >>> identifiers early makes sense, as you only have to inspect the first
>>> >>> byte.
>>> >>> But it gets complicated, because you don’t want to use 8 bytes for
>>> >>> some
>>> >>> stream types and you don’t want the bits at some random location in a
>>> >>> decoded 8 byte representation either.
>>> >>>
>>> >>>
>>> >>>
>>> >>> Regardless of bit placement, encoding state using bits is not ideal
>>> >>> when
>>> >>> considering variable length encoding because you now use two bits for
>>> >>> length
>>> >>> and two bits for stream type, leaving only 16 different streams
>>> >>> before the
>>> >>> stream identifier needs to use two bytes, and so forth.
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> Kind Regards,
>>> >>>
>>> >>> Mikkel Fahnøe Jørgensen
>>> >>>
>>> >>>
>>> >>>
>>> >>> On 13 October 2017 at 21.50.06, Hugues Fafard (fafard@in.tum.de)
>>> >>> wrote:
>>> >>>
>>> >>> I see, you used the 2 least significant bits to encode that
>>> >>> information. When only using one bit to indicate the direction, it
>>> >>> boiled down to odd/even which more or less made sense, but when using
>>> >>> 2 bits that breaks apart.
>>> >>>
>>> >>> Why not use the most significant bits instead? That way, getting the
>>> >>> 'clean' stream ID without the flags would be as simple doing a `&
>>> >>> 0x3F...FF` instead of bit-shifting things around. Similarly, encoding
>>> >>> the stream ID would just entail `| 0x?0...00` to set the appropriate
>>> >>> bits and also avoid bit-shifts.
>>> >>>
>>> >>> Regards,
>>> >>> Hugues
>>> >>>
>>> >>> On 2017-10-13 20:51, Ryan Hamilton wrote:
>>> >>> > As I understand the discussions at the interim, we've decided to
>>> >>> > allow streams to be unidirectional or bidirectional. I support this
>>> >>> > idea and was motivated to write up an idea I've been thinking about
>>> >>> > for a while. In the same way that we use a bit in the stream ID to
>>> >>> > identify the client vs server nature of the stream, we can use a
>>> >>> > bit to identify the directionality. This divides the stream ID
>>> >>> > space neatly into 4 distinct spaces (much like the 2 two we have
>>> >>> > today: client/server). In addition this means that a stream ID
>>> >>> > always uniquely identifies a single stream, and frames which
>>> >>> > mention stream ID (STREAM, MAX_STREAM_ID, MAX_STREAM_DATA,
>>> >>> > RST_STREAM, etc) do not need to explicitly convey the
>>> >>> > directionality as fields in those frames (or implicitly based on
>>> >>> > the directionality of the frames themselves).
>>> >>> >
>>> >>> > https://github.com/quicwg/base-drafts/pull/872
>>> >>> >
>>> >>> > Cheers,
>>> >>> >
>>> >>> > Ryan
>>> >>>
>>> >>>
>>> >>
>>> >>
>>> >
>>
>>
>