Re: [hybi] frame length encoding

John Tamplin <jat@google.com> Sat, 21 August 2010 19:40 UTC

Return-Path: <jat@google.com>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id E24AC3A6844 for <hybi@core3.amsl.com>; Sat, 21 Aug 2010 12:40:32 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -105.124
X-Spam-Level:
X-Spam-Status: No, score=-105.124 tagged_above=-999 required=5 tests=[AWL=0.852, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h19dBFPTBJY4 for <hybi@core3.amsl.com>; Sat, 21 Aug 2010 12:40:31 -0700 (PDT)
Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.35]) by core3.amsl.com (Postfix) with ESMTP id B24EB3A6801 for <hybi@ietf.org>; Sat, 21 Aug 2010 12:40:30 -0700 (PDT)
Received: from wpaz37.hot.corp.google.com (wpaz37.hot.corp.google.com [172.24.198.101]) by smtp-out.google.com with ESMTP id o7LJf37b029451 for <hybi@ietf.org>; Sat, 21 Aug 2010 12:41:03 -0700
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1282419664; bh=sTqEbsZ1jL4CFB53eFBOoGwTM+k=; h=MIME-Version:In-Reply-To:References:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Vr7zayBUdMlEaV76x95NUDvEArHuzYnIJvMqlWggQac9pv21kT18aRC8PGhzemyr5 1sVp7ysOpDbPaR2vkbX0A==
DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:in-reply-to:references:from:date:message-id: subject:to:cc:content-type:x-system-of-record; b=oKcReiyyE5HjGZMTrSDxA53mPRixx76cFl5FHak1nIoV+tlr2u4AXHt/fvS4bNhhc joM92FlLSgXGETPxJ2G0Q==
Received: from gyg13 (gyg13.prod.google.com [10.243.50.141]) by wpaz37.hot.corp.google.com with ESMTP id o7LJf2MX003512 for <hybi@ietf.org>; Sat, 21 Aug 2010 12:41:02 -0700
Received: by gyg13 with SMTP id 13so2622889gyg.2 for <hybi@ietf.org>; Sat, 21 Aug 2010 12:41:02 -0700 (PDT)
Received: by 10.151.78.6 with SMTP id f6mr3398161ybl.68.1282419662135; Sat, 21 Aug 2010 12:41:02 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.151.60.3 with HTTP; Sat, 21 Aug 2010 12:40:41 -0700 (PDT)
In-Reply-To: <8dea23aa73d8065b3f286852af659362.squirrel@sm.webmail.pair.com>
References: <AANLkTimKbmcpgx8k0uXUWvCO=8w9pPrtV=3y4qh6363k@mail.gmail.com> <20100820192927.GA32620@1wt.eu> <4C6EEA55.2050205@hs-weingarten.de> <AANLkTinHqxUOZaVANFpC52t8FfgNw2L5_A-s9Az3Fm7p@mail.gmail.com> <9038007a07cb2e7f2659663b8bc6af82.squirrel@sm.webmail.pair.com> <8586ffdbc1c035a949df3965da5f489a.squirrel@sm.webmail.pair.com> <AANLkTinkYMN8LyU7432v2PZjrQ0Z7cN7mcwwzYwCwhON@mail.gmail.com> <8dea23aa73d8065b3f286852af659362.squirrel@sm.webmail.pair.com>
From: John Tamplin <jat@google.com>
Date: Sat, 21 Aug 2010 15:40:41 -0400
Message-ID: <AANLkTim_-pAk8N8v2QTsBrk2qvArKXXZeESUuDdYZJ7u@mail.gmail.com>
To: shelby@coolpage.com
Content-Type: multipart/alternative; boundary="0015174bed786a217c048e5a9849"
X-System-Of-Record: true
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] frame length encoding
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 21 Aug 2010 19:40:33 -0000

On Sat, Aug 21, 2010 at 1:31 PM, Shelby Moore <shelby@coolpage.com> wrote:

> I assume that reserved bit is in the size field because all the other
> 8-bit groups of bit fields were allocated? That wastes 7-bits. We could
> recover the 7-bits and keep the reserved bit, if we are willing to have a
> header which is not byte aligned (1 extra bit in length), but the code
> gets more convoluted:
>

It isn't in the size field, it is a separate reserved bit.  It is where it
is because there was a request that the opcode be aligned on a nibble
boundary for easily reading a hex dump (admittedly minor benefit) -- any of
the fields could be rearranged however you desire without impacting anything
functionally.  The base header has 16 bits total, none of them wasted
(though 3 reserved, plus additional opcode values reserved).


> Why did you decide to put a reserved bit in middle of a size field if that
> bit is not already allocated to specific use?
>

The reserved bits are reserved because we haven't decided how to use them.
 Some discussions we have had about frame-by-frame compression or extension
metadata would need a single reserved bit in the header, the opcode field
could be extended, and there are likely things we haven't thought of yet
that could use it.


> And just in case there is ever a use case for the frames larger than 126
> but less than 65535 in size.
>
> Agreed it is only the 126 frame length that has any penalty.
>
> And if we don't need the extra reserved bit (or if we can use a 1 bit
> longer header), then there is no penalty at all.
>
> But I guess the logic is that it is better throw away 7 bits for the 126
> to 65535 frame byte sizes, than to add 1 bit to frame smaller than 126
> bytes in size?
>
> 7 bits / (126 x 8 bits) = 0.7%
>
> The break even point is 126 / 7 = 18 byte frame sizes.


Depending on the app, more than 98% of real-world WebSocket frames should
fit into 126 bytes after we add compression support.  Paying one bit for
those 98% seems a poor trade to save 7 bits on the <<2% frames which would
be between 127 and 64k.  There is also a threshold effect here -- if we
never need that reserved bit, then it was free to use it.  However, if we
turn out to have needed it, it will cost us a minimum of 1 byte to get it
back by adding an extension opcode.


> We would need to know the distribution of frame sizes we expect to make a
> decision of what is more cost effective.  But it is minor in either case,
> and the bit twiddling for non-byte aligned headers has some cost mostly in
> terms of software error.


I published such data for GWT Quake and Wave in April -
http://www.ietf.org/mail-archive/web/hybi/current/msg01810.html - since
then, I have add percentiles of frames <=126 bytes, assuming stream-based
compression with a 12-bit window: 98.88%/99.03% for GWT Quake S->C (2
trials), 99.98%/99.97% GWT Quake C->S, 98.22% Wave C->S, 98.31% Wave S->C.

Okay but we could get it back if we want to have non-byte aligned headers.


No, I think that is a non-starter, as it adds a great deal of complexity for
very little gain.

-- 
John A. Tamplin
Software Engineer (GWT), Google