Re: [hybi] preliminary WebSockets compression experiments

Roberto Peon <fenix@google.com> Fri, 23 April 2010 22:23 UTC

Return-Path: <fenix@google.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 B5D2A3A69A2 for <hybi@core3.amsl.com>; Fri, 23 Apr 2010 15:23:51 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -103.376
X-Spam-Level:
X-Spam-Status: No, score=-103.376 tagged_above=-999 required=5 tests=[BAYES_50=0.001, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
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 nV79uKMnBxcd for <hybi@core3.amsl.com>; Fri, 23 Apr 2010 15:23:45 -0700 (PDT)
Received: from smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by core3.amsl.com (Postfix) with ESMTP id 759BE3A6981 for <hybi@ietf.org>; Fri, 23 Apr 2010 15:23:44 -0700 (PDT)
Received: from hpaq14.eem.corp.google.com (hpaq14.eem.corp.google.com [10.3.21.14]) by smtp-out.google.com with ESMTP id o3NMNVL8004551 for <hybi@ietf.org>; Fri, 23 Apr 2010 15:23:32 -0700
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1272061412; bh=8HphokDCkM/7PLvCg/zaVryxFH4=; h=MIME-Version:In-Reply-To:References:Date:Message-ID:Subject:From: To:Cc:Content-Type; b=sPadj+sA0bVa7RmCWqvkmlCn1yYIsWW5D+FdMESLHzMVTUh1Td5mIpLwlGzD0f0pR 5doANRLjw7y2TRfPSol6Q==
DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:in-reply-to:references:date:message-id:subject:from:to: cc:content-type:x-system-of-record; b=QMthwfz8MXQcIuBG668g4Adiu2t8IIlFG4A7UXzkSaU+AwAJdwzke3cfs0WhJVzyz 5KN6MLpAH1cmaBPhvfLoQ==
Received: from gxk25 (gxk25.prod.google.com [10.202.11.25]) by hpaq14.eem.corp.google.com with ESMTP id o3NMNTW3010698 for <hybi@ietf.org>; Sat, 24 Apr 2010 00:23:29 +0200
Received: by gxk25 with SMTP id 25so5752390gxk.11 for <hybi@ietf.org>; Fri, 23 Apr 2010 15:23:29 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.150.119.11 with SMTP id r11mr675935ybc.334.1272061407480; Fri, 23 Apr 2010 15:23:27 -0700 (PDT)
Received: by 10.150.184.18 with HTTP; Fri, 23 Apr 2010 15:23:27 -0700 (PDT)
In-Reply-To: <z2w3f94964f1004231511u57f0d702z78e582b5481a2877@mail.gmail.com>
References: <q2z3f94964f1004231247zc7b60dc3l5fbb4748d129c3c@mail.gmail.com> <z2o2a10ed241004231448l7a63e329p98e04fbe1a750539@mail.gmail.com> <z2w3f94964f1004231511u57f0d702z78e582b5481a2877@mail.gmail.com>
Date: Fri, 23 Apr 2010 15:23:27 -0700
Message-ID: <v2oad99d8ce1004231523jcd948913g3606dfc340a9d1a0@mail.gmail.com>
From: Roberto Peon <fenix@google.com>
To: John Tamplin <jat@google.com>
Content-Type: multipart/alternative; boundary="000e0cd6cf16534c9a0484eee07e"
X-System-Of-Record: true
Cc: hybi@ietf.org
Subject: Re: [hybi] preliminary WebSockets compression experiments
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, 23 Apr 2010 22:23:51 -0000

Here is another thing to note.
If compression is optional and/or negotiated, it is likely that it will
either not be implemented, or it will be turned off by various end-user
devices that wish to inflate benchmark numbers.

SPDY requires compression support over the headers of certain control
frames. To date, we've not seen a case where this has resulted in a larger
request than raw, and it does provide for at least the availability of the
gzip functionality at the endpoint.

For Websockets, if we use gzip, the decision to do so should be made
*solely* by the sender of that data. There should probably be no
negotiation, else we'll end up with liars and cheats again.
-=R

On Fri, Apr 23, 2010 at 3:11 PM, John Tamplin <jat@google.com> wrote:

> On Fri, Apr 23, 2010 at 5:48 PM, Mike Belshe <mike@belshe.com> wrote:
>
>> *Memory Consumption:*
>> BTW - zlib, using the configuration you specified, might use a surprising
>> amount of RAM (to the tune of ~250KB!).  I suspect you want to decrease the
>> window size. Brian Olson already ran this experiment a while back with SPDY
>> and his results are here.  It would be interesting to see if you reach the
>> same conclusion.
>>
>> groups.google.com/group/spdy-dev/browse_thread/thread/dfaf498542fac792?pli=1
>>
>> As a result of Brian's work, SPDY decreased the windowBits from 15 to 11.
>>  This reduces the memory footprint substantially, while only leading to
>> modest reduction in compression ratios.
>>
>
> Thanks for the pointer -- I will try that out.
>
>
>> *On Generically Compressing A Stream:*
>> While we wanted to have SPDY provide required compression, in the end we
>> find it likely a bad idea.  Compressing the stream is never as good as
>> compressing the content.  For example, if the content can compress the
>> image, there is no point in having the stream redundantly (and likely
>> less-effectively) compress it.  Since most developers will get the content
>> compressed correctly, that is the right layer to do so; rather than having
>> the channel blindly compress what is already done.  We might revisit this
>> approach if new data arises, though.
>>
>> SSL has taken a similar approach.  When the protocol was designed, the
>> authors had the foresight to include compression negotiation in addition to
>> cypher negotiation as part of the handshake.  They did this because
>> compression should be applied before encryption (compressing encrypted data
>> is never good).  But, what do browsers today negotiate?  The major browsers
>> all advertise the empty-set of supported compression algorithms (meaning
>> don't do compression).  Why?  because compressing the stream blindly when
>> the application content is already compressed is inefficient.
>>
>> Anyway - those are two protocols which are opting not to do stream-based
>> compression and instead requiring the content provider to make the choice
>> (like HTTP does).  I think this matches your conclusion that you shouldn't
>> just compress everything.
>>
>
> I agree with the basic premise that the application can do a better job
> compressing the data than some generic algorithm -- my compression
> background is chess endgame databases where application-specific compression
> algorithms are much better than generic ones.  However, I don't know about
> trying to implement that in JS along with a corresponding server-side
> implementation.
>
> For HTTP, most servers are configured to compress things automatically if
> the client supports it, typically with a blacklist of file types not to
> compress (granted, you can pre-compress static content and serve that, and
> some servers may be intentionally configured to not compress other data).
>  Clearly using gzip compression on HTTP traffic is generally a good thing,
> and especially in the case of mobile or other low-bandwidth networks.
>
> As the GWT Quake example shows, even data that you wouldn't think is
> compressible (and isn't if you don't maintain compression state) compresses
> quite well.  With the safety valve of allowing uncompressed frames even when
> compression has been negotiated, I don't see how it can be a bad thing.  The
> server-side API might allow a way for the particular service on the other
> end of the socket to deny compression if it knows its data can't benefit,
> but that is really beyond the scope of the wire format.
>
> It would be feasible to provide an API for JS to call for compressing data
> and sending it itself, but there are a couple of problems:
>  - JS currently doesn't have any efficient way to manipulate binary data
>  - in the common case, it just adds extra work for the developer and extra
> code to download
>
> I think that might be a good idea once the binary data problem is solved,
> but I think a default case of allowing reasonable compression on the stream
> automatically is a good idea.
>
> --
> John A. Tamplin
> Software Engineer (GWT), Google
>
> _______________________________________________
> hybi mailing list
> hybi@ietf.org
> https://www.ietf.org/mailman/listinfo/hybi
>
>