Re: [hybi] hum #3: Message

Jamie Lokier <jamie@shareable.org> Fri, 06 August 2010 01:20 UTC

Return-Path: <jamie@shareable.org>
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 667A63A6893 for <hybi@core3.amsl.com>; Thu, 5 Aug 2010 18:20:18 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.521
X-Spam-Level:
X-Spam-Status: No, score=-1.521 tagged_above=-999 required=5 tests=[AWL=-0.934, BAYES_00=-2.599, FAKE_REPLY_C=2.012]
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 P50LyXbtzkKr for <hybi@core3.amsl.com>; Thu, 5 Aug 2010 18:20:17 -0700 (PDT)
Received: from mail2.shareable.org (mail2.shareable.org [80.68.89.115]) by core3.amsl.com (Postfix) with ESMTP id 061113A6887 for <hybi@ietf.org>; Thu, 5 Aug 2010 18:20:17 -0700 (PDT)
Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from <jamie@shareable.org>) id 1OhBc5-0000JY-JL; Fri, 06 Aug 2010 02:20:45 +0100
Date: Fri, 06 Aug 2010 02:20:45 +0100
From: Jamie Lokier <jamie@shareable.org>
To: Greg Wilkins <gregw@webtide.com>
Message-ID: <20100806012045.GH27827@shareable.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <AANLkTi=q_XEjKyK5vzFQhsZJOaxDh4QgXY1YnBJbG68P@mail.gmail.com>
User-Agent: Mutt/1.5.13 (2006-08-11)
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: Fri, 06 Aug 2010 01:20:19 -0000

Greg Wilkins wrote:
> Eitherway, I'd like to express strong support for the main parts of the hum:
> 
>     *  "Message" is a protocol unit with an end
>     * A message may be composed of one or more "frame"s
>     * Each frame has a length indication
> 
> 
> But I agree with everybody about the arguments for and against the
> various length encodings. I think the reason is that everybody is
> right!
> 
> Sometimes it is more efficient to send big content without chunking
> it.  eg in Jetty we use the NIO gather write mechanism to send a
> header from a memory buffer with a file mapped buffer of content.
> This means the file is sent to the network interface without going via
> user space memory.
> But then I also very very rarely see any server side developers set
> the content-length of dynamic content, so that is almost always best
> sent as chunks.  You can have some very large dynamic content coming
> out of DB selects etc.
> 
> 
> I think the best solution is  fragmentation plus a variable length
> encoding since this allows:
> 
>  + chunking of dynamic content
>  + sending of big content as a single frame
>  + minimal cost in bytes for the most frequent little messages.
>  + having fragments in the base protocol means that all extensions
> must handle them and thus it makes it easier to add extensions like
> multiplexing without breaking other things.

I agree.  Being able to send big content as a single frame is
certainly simpler than having to split.

And I think that's likely to result in fewer buggy implementations
than a fixed header.  If there's a small maximum chunk, poor
implementations may implement send-splitting wrong, but go undetected
for years if most applications use messages that fit in a single
chunk.  Whereas it's hard to screw up a variable length encoding, when
you have to get it right for common usages.

I don't think multiplexing is helped or hindered by having fragments
in the base protocol.  A multiplexing implementation is the same
either way.  Proxying between a multiplexed and non-multiplexed stream
is much the same either way.

But I notice fragments are necessary in any situation where you might
want to:

   + abort a message in progress
   + inject a control message

For example when forwarding a large message, if an error is detected
by the forwarder, it might want to abort the message and follow it by
a control message describing the error it has received and start an
orderly close.

Without fragments, the only thing a forwarder could do would be to
close the socket, which gives very little information, not even saying
if it's the forwarder or the earlier sender that failed.

> The main down side I can think of is that it makes it harder to word
> align header and data, but then I don't see a large demand for that.

I don't think there is any practical overhead to frame header parsing
on modern hardware.  All variations we've talked about are extremely
simple.  However, there may be overhead in moving the data to some
place that benefits from alignment.  Even simple copying can benefit.

   + Answer: Allow a 1-byte padding message.  Let's call it 0x00 for
     simplicity.  Senders can pad if they think it'll improve efficiency.
     Receivers ignore it.

-- Jamie