Re: timestamps encoding (was: Re: Straw Poll: Restore Header Table and Static Table Indices)

"Martin Nilsson" <nilsson@opera.com> Wed, 22 October 2014 01:17 UTC

Return-Path: <ietf-http-wg-request@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 136231A8901 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 21 Oct 2014 18:17:04 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.912
X-Spam-Level:
X-Spam-Status: No, score=-6.912 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3yXrYTiaTWwg for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 21 Oct 2014 18:16:59 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 409DD1A88FA for <httpbisa-archive-bis2Juki@lists.ietf.org>; Tue, 21 Oct 2014 18:16:59 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.72) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1XgkVR-0002Nc-QM for ietf-http-wg-dist@listhub.w3.org; Wed, 22 Oct 2014 01:14:29 +0000
Resent-Date: Wed, 22 Oct 2014 01:14:29 +0000
Resent-Message-Id: <E1XgkVR-0002Nc-QM@frink.w3.org>
Received: from lisa.w3.org ([128.30.52.41]) by frink.w3.org with esmtp (Exim 4.72) (envelope-from <nilsson@opera.com>) id 1XgkVK-0002Mt-7N for ietf-http-wg@listhub.w3.org; Wed, 22 Oct 2014 01:14:22 +0000
Received: from mail-wi0-f173.google.com ([209.85.212.173]) by lisa.w3.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.72) (envelope-from <nilsson@opera.com>) id 1XgkVJ-00066l-9L for ietf-http-wg@w3.org; Wed, 22 Oct 2014 01:14:22 +0000
Received: by mail-wi0-f173.google.com with SMTP id fb4so23660wid.6 for <ietf-http-wg@w3.org>; Tue, 21 Oct 2014 18:13:54 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:to:subject:references:date :mime-version:content-transfer-encoding:from:organization:message-id :in-reply-to:user-agent; bh=dAL++HP611wdFC3CiUekOpgig975eAib08nG6toXTwU=; b=Br2Zy9PoQr6uh4fIlDvySv0RPzQVAez3Aw3JwRjH8XYuGboNgVgwViF7utYdBch1CQ lbCM2+zZeCia7VXuDMUzDZxc0KzGdWaXi3ePsjLng/Qv9r1Dsw9XyOo6pPKOG8WtKtHg MB5WjY7Pg+IBgV3TFBev+X9aJlaWWnaBezGN9WuBF+Ij7Vq0R7LZM0qlAfHNHG72Yt0g mavVnMoI5QbaPWRZB9Fi00U1NR6xd9oKYNkdVZi/hKEHTbXuDQhhzivwiDi6p/jrZe9M J9jlF22ICrcNKzdUAyzMQrb0RiYmVKNURmaJwr2OOX40nRj9iY3qZHIbtTzJdaPEgfIy cxhw==
X-Gm-Message-State: ALoCoQmLNQDSgwXP5rrVSvnWizPxdVybO1lJiWa6ASqL4BWbj5joAKuZfkwmxdkVS10lASbb/axC
X-Received: by 10.194.82.74 with SMTP id g10mr46326wjy.116.1413940434307; Tue, 21 Oct 2014 18:13:54 -0700 (PDT)
Received: from beryllium.oslo.osa (c-151ce353.03-25-6c6b7010.cust.bredbandsbolaget.se. [83.227.28.21]) by mx.google.com with ESMTPSA id hh13sm123346wib.1.2014.10.21.18.13.53 for <ietf-http-wg@w3.org> (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 21 Oct 2014 18:13:53 -0700 (PDT)
Content-Type: text/plain; charset="utf-8"; format="flowed"; delsp="yes"
To: ietf-http-wg@w3.org
References: <20141016091626.GC3079@1wt.eu> <34008D72-5800-412E-A276-81C6C7BFA9E2@mnot.net> <20141020165353.GA25743@1wt.eu> <8F120E2F-704E-44CB-ACF2-C743B870B2B6@mnot.net> <CAP+FsNdOHVj=YTE35Vj7mbED0OKghd-mpnFZSMcZNBM3JybJDg@mail.gmail.com> <20141021092505.GA30397@1wt.eu> <52739.1413883975@critter.freebsd.dk> <20141021094425.GC30397@1wt.eu> <54462F3F.30502@gmx.de> <20141021102016.GG30397@1wt.eu> <20141021142451.GJ30397@1wt.eu>
Date: Wed, 22 Oct 2014 03:13:55 +0200
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: Martin Nilsson <nilsson@opera.com>
Organization: Opera Software ASA
Message-ID: <op.xn3xphjviw9drz@beryllium.oslo.osa>
In-Reply-To: <20141021142451.GJ30397@1wt.eu>
User-Agent: Opera Mail/12.17 (Win32)
Received-SPF: pass client-ip=209.85.212.173; envelope-from=nilsson@opera.com; helo=mail-wi0-f173.google.com
X-W3C-Hub-Spam-Status: No, score=-3.5
X-W3C-Hub-Spam-Report: AWL=-2.801, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001
X-W3C-Scan-Sig: lisa.w3.org 1XgkVJ-00066l-9L 5b845288446bcd1c74dc8e2982c7be33
X-Original-To: ietf-http-wg@w3.org
Subject: Re: timestamps encoding (was: Re: Straw Poll: Restore Header Table and Static Table Indices)
Archived-At: <http://www.w3.org/mid/op.xn3xphjviw9drz@beryllium.oslo.osa>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/27667
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

On Tue, 21 Oct 2014 16:24:51 +0200, Willy Tarreau <w@1wt.eu> wrote:

>
> The example code below converts valid strings to their compacted form
> and leaves the non-convertable ones intact. The converted string's format
> indicates what format it's in (ie: if it begins with 0xA its a compact  
> one).
> The gains are interesting, just tested on example.com, there are 3 dates
> there, 24 bytes each, and reduced to 5 bytes each, that's 57 bytes saved
> in one response header (19 bytes saved per valid header).
>

That's before huffman encoding.

Taking a now:ish timestamp of 1413938411 creates the byte sequence  
0a.84.89.46.56. These 5 bytes are encoded with 89 bits after huffman  
encoding, whereas the 10 byte numeric literal "1413938411" is encoded with  
56 bits. Not completely fair since you have an encoding token in front,  
which is needed here to distinguish between time and time offsets. If we  
pick "t" to mean time, which is encoded with 5 bits, we get 64 bits for  
your method and 61 bits for ASCII, for this example. For this size of  
numbers you'll get an average of 4*18.2 = 72.8 bits while ASCII gives  
10*5.7 = 57 bits (plus encoding token).

/Martin Nilsson

-- 
Using Opera's mail client: http://www.opera.com/mail/