Re: [hybi] frame length encoding

Pieter Hintjens <ph@imatix.com> Sat, 21 August 2010 19:23 UTC

Return-Path: <pieterh@gmail.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 5CE683A695D for <hybi@core3.amsl.com>; Sat, 21 Aug 2010 12:23:50 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.977
X-Spam-Level:
X-Spam-Status: No, score=-1.977 tagged_above=-999 required=5 tests=[AWL=0.000, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622]
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 P+9WkT41watL for <hybi@core3.amsl.com>; Sat, 21 Aug 2010 12:23:48 -0700 (PDT)
Received: from mail-vw0-f44.google.com (mail-vw0-f44.google.com [209.85.212.44]) by core3.amsl.com (Postfix) with ESMTP id 24B403A6847 for <hybi@ietf.org>; Sat, 21 Aug 2010 12:23:48 -0700 (PDT)
Received: by vws10 with SMTP id 10so4467852vws.31 for <hybi@ietf.org>; Sat, 21 Aug 2010 12:24:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:sender:received :in-reply-to:references:from:date:x-google-sender-auth:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=KlI9AYz26UGSzsxn4Zjoej3KZ48/Cm7pf74uuWk33vs=; b=dmphvbQBymwx3EsdflrpMjSIT5qTwtwF79DqqTGcbOxD5Vyur9Ar/EyMbBweU/Tqjb s2iQxgPPDP5Eaz/NGvCw7DNqtklxHzdGTkO7IV53w/BDk+hBVMiXSwU96ZHdM2f1cH6p e3dhKO1YZvN4FQfjFtpIJ4iMTPfPvaXGf7c5A=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=mMbhevWSCGuZ/RqYn29WklYrEK1R4DF5oiVqxq7jo1cGcKOYyQBnyzx+DJcVeCS+4L ZhZsmCtgfJ2F4UFemOnQNlu+Fiz2ZOls4remfLNuf4QxnarUz6dPDfIUdou+5njDVIam X1qsFFG2Q+i74nhLiXVSAKCReFGDNcDFLzET4=
Received: by 10.220.121.206 with SMTP id i14mr2002105vcr.1.1282418661583; Sat, 21 Aug 2010 12:24:21 -0700 (PDT)
MIME-Version: 1.0
Sender: pieterh@gmail.com
Received: by 10.220.167.17 with HTTP; Sat, 21 Aug 2010 12:24:01 -0700 (PDT)
In-Reply-To: <AANLkTim3KRq1arso7wN_b+1TH3sWabYW6uFu7AbYw6-P@mail.gmail.com>
References: <AANLkTimKbmcpgx8k0uXUWvCO=8w9pPrtV=3y4qh6363k@mail.gmail.com> <20100820192927.GA32620@1wt.eu> <4C6EEA55.2050205@hs-weingarten.de> <AANLkTinHqxUOZaVANFpC52t8FfgNw2L5_A-s9Az3Fm7p@mail.gmail.com> <AANLkTinvkxMP8FYz9xjDu_Kt9FfzYotgsqXUDB4MZMEo@mail.gmail.com> <AANLkTim3KRq1arso7wN_b+1TH3sWabYW6uFu7AbYw6-P@mail.gmail.com>
From: Pieter Hintjens <ph@imatix.com>
Date: Sat, 21 Aug 2010 21:24:01 +0200
X-Google-Sender-Auth: LT4sAzhwmErtOEXIPLiknQLPHnA
Message-ID: <AANLkTikhhajho895WyEoJMwMk9GJ98kA0Mjy5qr4apC8@mail.gmail.com>
To: John Tamplin <jat@google.com>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
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:23:50 -0000

On Sat, Aug 21, 2010 at 9:07 PM, John Tamplin <jat@google.com> wrote:

> So, this is exactly the same as option #1, except it allocates RSV2 to the
> short length field.  As such, it doesn't address the primary complaint
> people had about option #1, which is that an implementation that flushes a
> buffer a WebSocket frame is likely to use something in the 4-64k buffer
> size, and would therefore have to use the 8-byte version.

John, thanks for taking the time to collect all the knowledge we've
gathered so far and steer this group towards consensus.

The advantage of #0 is simplicity.  Frames can be read and written
with the utter minimum of logic: no special cases, no ceilings, no bit
mangling.

Simplicity of the framing is also an essential part of reducing CPU
cycles needed to process frames, which matters in low-latency
scenarios.

Our main use case for high performance messaging is market data and
the generally-accepted average size of a FIX message is 157 bytes.  We
also have Twitter messages at 140 bytes and SMS text messages at 160
bytes.  This argues (gently) that a "short" message is under 255 bytes
rather than 127.

As for 64-bit long frames, it's again a matter of simplicity.  With
32-bit frames some use cases MUST switch to fragmentation.

We've been using the 8/64 framing model for several years in ZeroMQ
and it has proven to be robust and optimally fast, see
http://www.zeromq.org/whitepapers:design-v01#toc5.

At the same time if the group's consensus is towards a more complex
length encoding we'd look at adopting that in ZeroMQ.

-
Pieter Hintjens
iMatix - www.imatix.com