Re: [hybi] frame length encoding

"Shelby Moore" <shelby@coolpage.com> Sun, 22 August 2010 03:22 UTC

Return-Path: <shelby@coolpage.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 601FF3A684B for <hybi@core3.amsl.com>; Sat, 21 Aug 2010 20:22:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.132
X-Spam-Level:
X-Spam-Status: No, score=-2.132 tagged_above=-999 required=5 tests=[AWL=0.467, 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 IA6YrWUDgdEg for <hybi@core3.amsl.com>; Sat, 21 Aug 2010 20:22:36 -0700 (PDT)
Received: from www5.webmail.pair.com (www5.webmail.pair.com [66.39.3.83]) by core3.amsl.com (Postfix) with SMTP id 1CD753A6823 for <hybi@ietf.org>; Sat, 21 Aug 2010 20:22:35 -0700 (PDT)
Received: (qmail 84514 invoked by uid 65534); 22 Aug 2010 03:23:07 -0000
Received: from 121.97.54.174 ([121.97.54.174]) (SquirrelMail authenticated user shelby@coolpage.com) by sm.webmail.pair.com with HTTP; Sat, 21 Aug 2010 23:23:07 -0400
Message-ID: <5628917d835c46121071f82037969615.squirrel@sm.webmail.pair.com>
In-Reply-To: <1282435090.2014.12.camel@tng>
References: <AANLkTimKbmcpgx8k0uXUWvCO=8w9pPrtV=3y4qh6363k@mail.gmail.com> <alpine.DEB.2.00.1008212037190.27211@tvnag.unkk.fr> <AANLkTinrsT+wV48nHvVW_1ChGYffkq7jisU2-PZnMyKg@mail.gmail.com> <alpine.DEB.2.00.1008212123460.27211@tvnag.unkk.fr> <20ef7ed5e135c57c1ee5a741658b9d98.squirrel@sm.webmail.pair.com> <1282423311.2014.6.camel@tng> <b09e8e740ef2b5b5ec3c85a5d9dcfd08.squirrel@sm.webmail.pair.com> <AANLkTikE8+oEbviWrPO=Pi+=CHSMnCD9KYmH8EMxMktw@mail.gmail.com> <1282435090.2014.12.camel@tng>
Date: Sat, 21 Aug 2010 23:23:07 -0400
From: Shelby Moore <shelby@coolpage.com>
To: Patrick McManus <mcmanus@ducksong.com>
User-Agent: SquirrelMail/1.4.20
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Priority: 3 (Normal)
Importance: Normal
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] frame length encoding
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: shelby@coolpage.com
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: Sun, 22 Aug 2010 03:22:39 -0000

> On Sat, 2010-08-21 at 16:59 -0400, John Tamplin wrote:
>> On Sat, Aug 21, 2010 at 4:57 PM, Shelby Moore <shelby@coolpage.com>
>> wrote:
>
>>          Can you simply rewrite
>>         one sector on disk and the memory manager remaps?
>>
>>
>> I haven't tried it personally, but I would suspect you could use
>> TCP_CORK, write a header, use sendfile to send a chunk of the file to
>> finish the frame, uncork, repeat until done.  I don't think there
>> would be any extra copying involved here, but you can't just issue the
>> sendfile and go on to the next message, you need some thread that will
>> queue up the next frame when it is ready.
>
> That is correct (and I have done this personally), you need multiple
> calls of the ZC API interleaved with the write of the chunk header.
> There is no copying of the data through the CPU just because it requires
> multiple calls. And there is no reason you couldn't implement some kind
> of writev() like API that lets you interleave copied and zero-copied
> data.
>
> And yes, multiple calls are more overhead than 1 call. but at 1 per 4GB,
> it really is inconsequential.

That is an extremely technical solution applicable to experienced sysadmins.

But WebSockets is supposed to be used also by web programming amateurs. 
It is much easier for them to issue a single sendFile() call from PHP,
Perl, Ruby, etc., without all the fuss and low-level network stack API
synchronization.