Re: [hybi] hum #3: Message

Scott Ferguson <ferg@caucho.com> Sat, 07 August 2010 19:21 UTC

Return-Path: <ferg@caucho.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 C30883A67E1 for <hybi@core3.amsl.com>; Sat, 7 Aug 2010 12:21:12 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[AWL=0.000, BAYES_00=-2.599]
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 OeZn9JUzjbzA for <hybi@core3.amsl.com>; Sat, 7 Aug 2010 12:21:11 -0700 (PDT)
Received: from smtp114.biz.mail.re2.yahoo.com (smtp114.biz.mail.re2.yahoo.com [66.196.116.99]) by core3.amsl.com (Postfix) with SMTP id 992763A63EC for <hybi@ietf.org>; Sat, 7 Aug 2010 12:21:11 -0700 (PDT)
Received: (qmail 2966 invoked from network); 7 Aug 2010 19:21:43 -0000
Received: from [192.168.1.11] (ferg@66.92.8.203 with plain) by smtp114.biz.mail.re2.yahoo.com with SMTP; 07 Aug 2010 12:21:41 -0700 PDT
X-Yahoo-SMTP: L1_TBRiswBB5.MuzAo8Yf89wczFo0A2C
X-YMail-OSG: C2JtT_wVM1lii5LVv821V.P2aHkarWt4thDpdCzkuhj8pyn KnMhsCJ2ycVCn7LK444YB.jXjnPY8Z9T4dY.ZoYtDz6njTZsk4Sz5qfxR2ZB 2Fben8T8Azvki7rSSMzJPe7_0SFJCaYmt2JeQ_7pQBQOqO_nWRJhNHLNBhkN owIIQMIS32apuinCAklCd5C9.CVKerkNuDCbnvSeuvKnivxN64RjGU9y3cjL RgeVRWhF3GBvPQOOTqLfSGIf9Yp0eAfxTqWPtHqJn_jg.PdbK6NW2eCHWuyc w5yHGzs2eXIznwt22I40aIXJE2XSo2FPGWmUx8.ljd0EZGRA1N.mDKQSic3v ld1abgNFltK6SmmYsAV5gpXe.aXtpXSXAW_tAAUfE4D9TJw8nPCa3qvl89aU WYIn_zvnld5IMt6uMNw--
X-Yahoo-Newman-Property: ymail-3
Message-ID: <4C5DB23F.102@caucho.com>
Date: Sat, 07 Aug 2010 12:21:35 -0700
From: Scott Ferguson <ferg@caucho.com>
User-Agent: Thunderbird 2.0.0.24 (X11/20100411)
MIME-Version: 1.0
To: Willy Tarreau <w@1wt.eu>
References: <F8E2F702-9F74-4316-B3B2-D5A731409ABF@apple.com> <AANLkTin=gO9D8K5NVhqCRKki-jrDmTYqF-gBjp9X41GN@mail.gmail.com> <4C5BF15E.1090608@noemax.com> <AANLkTinXLPmBACd3ji0V9wkAWmxOR7qBMED19KKMvJrd@mail.gmail.com> <AANLkTi=RWdqDDgy24C6qtUSr+5R5p=P15B=+aUZuE16Q@mail.gmail.com> <4C5C07D6.1030208@noemax.com> <AANLkTimj9RvzL8E+FmH=vT_TeECVNmDPXY0ymPnvBHSZ@mail.gmail.com> <4C5C31DF.3030608@caucho.com> <2286.1281126409.976140@puncture> <4C5CBAEB.3050809@caucho.com> <20100807043359.GD4387@1wt.eu>
In-Reply-To: <20100807043359.GD4387@1wt.eu>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
Cc: Server-Initiated HTTP <hybi@ietf.org>
Subject: Re: [hybi] hum #3: Message
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, 07 Aug 2010 19:21:12 -0000

Willy Tarreau wrote:
> On Fri, Aug 06, 2010 at 06:46:19PM -0700, Scott Ferguson wrote:
>   
>> Any of 16/64, or 8/16/64 or 8/32/64 would be fine, but 8/64 is a poor 
>> choice for chunking because 256 bytes is too small to be a reasonable 
>> chunk, and 64 bits is a waste. Suppose you're using a 8k buffer. With 
>> the 8-bit length, you need 32 chunks just to send the buffer. With the 
>> 64-bit length, you're wasting 6 bytes. With those as the only options, 
>> you're stuck between two bad choices.
>>     
>
> You're wasting 6 bytes per 8kB, so less than 0.07%. It's even less than
> the single byte you waste for 256 bytes (0.4%). The worst case is when
> you send 2048 bytes. You waste exactly 8 bytes by either 8 8-bit chunks
> or one 64-bit chunk, which in both cases represent 0.39%. But this is
> still equal to the minimum 8-bit chunk overhead. So in fact if we wanted
> to always have a lower overhead, we'd have to completely remove 8-bit
> chunks, but I don't think that would be a good idea.
>   

Let's look at the full comparison between 8/64 and 16/64. The values in 
the table below are frame overhead for various message/chunk sizes 
(8-bit length is a 2 byte frame, 16-bit length is 3 bytes, and 64-bit 
length is 9 bytes):

          8/64      16/64     64
  --------------------------------
  32      6.3%      9.3%     28.1%
  128     1.6%      2.3%      7.0%  
  256     3.5%      1.2%      3.5%
  512     1.8%      0.6%      1.8%
  2048    0.4%      0.1%      0.4%
  8192    0.1%      0.04%     0.1%

(Note that 8/64 only beats 16/64 in the upper left.)

Three ways of looking at the table:

  a) optimal length given a priori knowledge of the message size
  b) practical length given dynamic content. (When it's not known if a 
32 byte echo/print/write is the full message or the first part of a 
bigger message.)
  c) chunking

a) For optimal, it all depends on the message-length distribution. When 
messages are tweets, 8/64 is better (1.6% vs 2.3%). When messages are 
between 256 and 64k, 16/64 is better (0.6% vs 1.8% for a 512-byte 
message, and 0.15% vs 0.44% for the 2048-byte chunk example).

b) For dynamic content, the upper-right table values are the problem. 
The 28.1% and 7.0% are more than they need to be. Even so, it's still 
probably not worth shifting the content. So the optimal 8/64 becomes a 
practical 64-bit fixed length because it's not worth the effort to 
repack the data.

c) Chunks would be between 512 and 64k, depending on the 
implementation's buffer size. In that range, 16/64 is always superior. 
It's only the final chunk that might benefit from an 8-bit length.

Even though 16/64 is a better choice overall (given dynamic-content 
pragmatic issues, chunking needs, and uncertainty about the real-world 
message-length distribution), 8/64 is workable. The 28% and 7% overheads 
in the upper right are inelegant, and the extra chunking overhead is 
less efficient, but it's workable.

-- Scott

> So all in all, I think that the 64-bit csize always offers lower overhead
> than the 8-bit ones so it will always be more efficient above 2 kB than
> anything sent in 8-bit blocks, and the overhead is still small.
>
> Regards,
> Willy
>
>
>
>
>