Re: [hybi] hum #3: Message

Arman Djusupov <arman@noemax.com> Fri, 06 August 2010 13:01 UTC

Return-Path: <arman@noemax.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 D0A863A699A for <hybi@core3.amsl.com>; Fri, 6 Aug 2010 06:01:49 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.448
X-Spam-Level:
X-Spam-Status: No, score=-2.448 tagged_above=-999 required=5 tests=[AWL=0.151, 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 ZM-x6udMX+sv for <hybi@core3.amsl.com>; Fri, 6 Aug 2010 06:01:49 -0700 (PDT)
Received: from mail.noemax.com (mail.noemax.com [64.34.201.8]) by core3.amsl.com (Postfix) with ESMTP id BF8D73A6833 for <hybi@ietf.org>; Fri, 6 Aug 2010 06:01:48 -0700 (PDT)
Received: from [192.168.1.21] by mail.noemax.com (IceWarp 9.4.1) with ASMTP (SSL) id OVI17223; Fri, 06 Aug 2010 16:02:23 +0300
Message-ID: <4C5C07D6.1030208@noemax.com>
Date: Fri, 06 Aug 2010 16:02:14 +0300
From: Arman Djusupov <arman@noemax.com>
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
To: Pieter Hintjens <ph@imatix.com>
References: <4C5AE93D.4040803@ericsson.com> <Pine.LNX.4.64.1008051758290.5947@ps20323.dreamhostps.com> <AANLkTik0kbh14s2JZARY2MFh0iNGV7H+B4Px4yG+wX44@mail.gmail.com> <71BCE4BF-D3F6-4F94-BE76-306BDF6A2E67@apple.com> <Pine.LNX.4.64.1008051930160.5947@ps20323.dreamhostps.com> <4C5B1695.6070704@gmx.de> <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>
In-Reply-To: <AANLkTi=RWdqDDgy24C6qtUSr+5R5p=P15B=+aUZuE16Q@mail.gmail.com>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
Cc: "hybi@ietf.org" <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 13:01:49 -0000

Pieter Hintjens wrote:
> I don't think this is accurate. Framing is to allow the reading of messages
> by a layer that does not need to know their semantics. Also to allow
> preallocation and protection against overflows. Fragmentation is to allow
> long messages to be handled in smaller buffers. I think in all cases we can
> assume the sender knows the length upfront.

Preallocating resources for the entire message is not always needed in order to consume it (e.g. forward only XML parsers can consume/transform GBs of XML data using a buffer of a few KBs). The same applies to chunking which does not require a single frame to fit into the input buffer since the implementation can read frames of arbitrary size using whatever input buffer is available. So the size of the frame/message is not always related to the size of the buffer.

We cannot assume that the sender necessarily knows the length of the data beforehand because there are cases when responses are getting generated on the fly by the server side script/code. In such cases the server side cannot predict the final size of the message unless it already has the response cached or buffered. So it either spends time waiting for the full response to be generated or starts sending it right way by using the chunked transfer encoding thus saving time and memory.

Arman