Re: [hybi] With deflate-stream, Close frame doesn't work as an end of data marker

Yutaka_Takeda@PlayStation.Sony.Com Tue, 01 March 2011 07:36 UTC

Return-Path: <Yutaka_Takeda@PlayStation.Sony.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 237EA3A69AB for <hybi@core3.amsl.com>; Mon, 28 Feb 2011 23:36:10 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -5.995
X-Spam-Level:
X-Spam-Status: No, score=-5.995 tagged_above=-999 required=5 tests=[AWL=0.269, BAYES_00=-2.599, HTML_MESSAGE=0.001, IP_NOT_FRIENDLY=0.334, RCVD_IN_DNSWL_MED=-4]
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 Gzxji3k8bB7U for <hybi@core3.amsl.com>; Mon, 28 Feb 2011 23:36:08 -0800 (PST)
Received: from paris.playstation.sony.com (nat.playstation.sony.com [69.36.131.254]) by core3.amsl.com (Postfix) with ESMTP id 58BC13A6AA4 for <hybi@ietf.org>; Mon, 28 Feb 2011 23:36:08 -0800 (PST)
Received: from constantine.playstation.sony.com ([162.49.67.15]) by paris.playstation.sony.com (Lotus Domino Release 8.5.1FP5) with ESMTP id 2011022823370325-263566 ; Mon, 28 Feb 2011 23:37:03 -0800
In-Reply-To: <AANLkTinTqHtG+HmjBm4n2yS3Ouz+Fw3i_R_Gf7qx0vn1@mail.gmail.com>
To: John Tamplin <jat@google.com>
MIME-Version: 1.0
X-KeepSent: D3C37398:B2A4BACA-88257846:002385CC; type=4; flags=0; name=$KeepSent
X-Mailer: Lotus Notes Release 7.0.2 September 26, 2006
Message-ID: <OFD3C37398.B2A4BACA-ON88257846.002385CC-88257846.0029DE5F@playstation.sony.com>
From: Yutaka_Takeda@PlayStation.Sony.Com
Date: Mon, 28 Feb 2011 23:37:17 -0800
X-MIMETrack: Serialize by Router on SCEA919ML04/SCEA(Release 8.5.1FP3|May 23, 2010) at 02/28/2011 11:37:02 PM, Serialize complete at 02/28/2011 11:37:02 PM, Itemize by SMTP Server on SCEA919ML02/SCEA(Release 8.5.1FP5|September 29, 2010) at 02/28/2011 11:37:03 PM, Serialize by Router on SCEA919ML02/SCEA(Release 8.5.1FP5|September 29, 2010) at 02/28/2011 11:37:11 PM, Serialize complete at 02/28/2011 11:37:11 PM
Content-Type: multipart/alternative; boundary="=_alternative 0029DE5C88257846_="
Cc: hybi@ietf.org
Subject: Re: [hybi] With deflate-stream, Close frame doesn't work as an end of data marker
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: Tue, 01 Mar 2011 07:36:10 -0000

Hi John,

hybi-bounces@ietf.org wrote on 02/28/2011 06:32:03 AM:

> [BTW - here is the thread where I first posted results of an
> experiment 
- http://www.ietf.org/mail-archive/web/hybi/current/msg01810.html
> ]
> 
> On Mon, Feb 28, 2011 at 4:52 AM, Greg Wilkins <gregw@webtide.com> wrote:
> > I'm +1 for compression within the frame.
> >
> > If we compress the framing, then intermediaries will have to
> > decompress in order to see framing and to know when to forward etc.
> > It also has significant debug issues as it makes it much harder to
> > decode a partial frame capture.
> >
> > I understand the argument that compression will not be as good, but I
> > think some compromise is necessary.
> 
> The framing is pretty small and it is hard to imagine much redundancy
> from the header (the opcode and reserved bits will be constant, but
> then you will interfere with the compression by all the constantly
> changing lengths), so I think little is lost by compressing only the
> payload.

Just to be clear, the compression does not have to be per payload of
a data frame, but can be entire stream of messages application passes in.
At the end of the message, though, F_SYNC_FLUSH is necessary to prevent 
receiver from waiting for the last compressed data to arrive from sender, 
but we should be aware that the compressor still maintains 32kB(or 
whatever 
it is configured for) of reference range in its context.

> 
> However, it does mean the implementation is more complicated, and I

It is actually very simple, in python for example:


        zlibObj = zlib.compressobj()

        def send(in_data):
                buf = zlibObj.compress(in_data)
                buf += zlibObj.flush(zilib.Z_SYNC_FLUSH)
                        :
                (construct frames/fragments and put into a queue)

Note: the 'zlibObj' has the same lifetime as that of WebSocket.


> don't believe this would be feasible using the stock inflate/deflate
> in Java for example.  I would not agree to just compressing each
> frame's payload independently -- my earlier experiments show this will
> frequently increase the size of the data and result in only modest
> savings compared to maintaining compression state over the life of the
> connection (while we are discussing it, 

Again, lifetime of the compression state/context can be the same. It 
just needs, Z_SYNC_FLUSH operation at the end of the 'WS-frame' to avoid 
unnecessary delay. Even compression was done for whole stream, we still 
need Z_SYNC_FLUSH per frame basis with the exact same reason - we cannot
delay the frame! (Unless we introduce nagle's algorithm like protocol
just for slightly better compression ratio, which I think would not be
feasible.) This, at least to me, looks more complicated.

I am aware that, if application passes in is very small message 
frequently, (Z_SYNC_FLUSH has to be done frequently), resulting 
compression ratio would not be that great. However, since we can not 
delay each frame, we need the Z_SYNC_FLUSH anyways. Therefore, there's 
no benefit in having compression layer under the framing layer.

As I mentioned earlier, the compression state can be shared between 
text and binary messages since they are not interleaved (even fragmented),
though it may be better to have dedicated compression state if we can
afford memory. Either way, we need to define the spec in the document.


- Yutaka


> we should talk about the
> parameters to use for deflate to minimize memory requirements on the
> server -- experiments done for compression in SPDY [mentioned in the
> linked thread] show you can get most of the benefit with more modest
> memory requirements using lower parameters).
> 
> It also means we have to agree on the details of how it should be
> specified, which is why the super-simple deflate-stream was added to
> the standard instead of trying to get agreement on something better.
> 
> --
> John A. Tamplin
> Software Engineer (GWT), Google
> _______________________________________________
> hybi mailing list
> hybi@ietf.org
> https://www.ietf.org/mailman/listinfo/hybi