Re: [apps-discuss] Concise Binary Object Representation (CBOR) -- support streaming

Carsten Bormann <cabo@tzi.org> Thu, 23 May 2013 07:50 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: apps-discuss@ietfa.amsl.com
Delivered-To: apps-discuss@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 598BD21F96DD for <apps-discuss@ietfa.amsl.com>; Thu, 23 May 2013 00:50:52 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -106.212
X-Spam-Level:
X-Spam-Status: No, score=-106.212 tagged_above=-999 required=5 tests=[AWL=0.037, BAYES_00=-2.599, HELO_EQ_DE=0.35, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3-wLYZDsIJ7c for <apps-discuss@ietfa.amsl.com>; Thu, 23 May 2013 00:50:46 -0700 (PDT)
Received: from informatik.uni-bremen.de (mailhost.informatik.uni-bremen.de [IPv6:2001:638:708:30c9::12]) by ietfa.amsl.com (Postfix) with ESMTP id 21AAB21F96F5 for <apps-discuss@ietf.org>; Thu, 23 May 2013 00:50:45 -0700 (PDT)
X-Virus-Scanned: amavisd-new at informatik.uni-bremen.de
Received: from smtp-fb3.informatik.uni-bremen.de (smtp-fb3.informatik.uni-bremen.de [134.102.224.120]) by informatik.uni-bremen.de (8.14.4/8.14.4) with ESMTP id r4N7ocfr023005; Thu, 23 May 2013 09:50:38 +0200 (CEST)
Received: from [192.168.217.105] (p54891D40.dip0.t-ipconnect.de [84.137.29.64]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by smtp-fb3.informatik.uni-bremen.de (Postfix) with ESMTPSA id 656EC3B29; Thu, 23 May 2013 09:50:38 +0200 (CEST)
Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\))
Content-Type: text/plain; charset="iso-8859-1"
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <255B9BB34FB7D647A506DC292726F6E1151A8ACB34@WSMSG3153V.srv.dir.telstra.com>
Date: Thu, 23 May 2013 09:50:37 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <964FB690-4904-4BC4-99A8-AAB57B21FB52@tzi.org>
References: <61CB1D18-BABC-4C77-93E6-A9E8CDA8326B@vpnc.org> <255B9BB34FB7D647A506DC292726F6E1151A8ACB34@WSMSG3153V.srv.dir.telstra.com>
To: "Manger, James H" <James.H.Manger@team.telstra.com>
X-Mailer: Apple Mail (2.1503)
Cc: "apps-discuss@ietf.org" <apps-discuss@ietf.org>
Subject: Re: [apps-discuss] Concise Binary Object Representation (CBOR) -- support streaming
X-BeenThere: apps-discuss@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: General discussion of application-layer protocols <apps-discuss.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/apps-discuss>
List-Post: <mailto:apps-discuss@ietf.org>
List-Help: <mailto:apps-discuss-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 23 May 2013 07:50:52 -0000

On May 23, 2013, at 03:49, "Manger, James H" <James.H.Manger@team.telstra.com> wrote:

> sizes have to be known upfront

Indeed.  The old "counted vs. delimited" debate.

JSON is delimited because is HAS TO BE -- counted is a non-starter for text formats (as amply demonstrated by FORTAN Hollerith data).

CBOR is counted because that is the best fit for a binary format.
Fast deserializers really benefit from knowing counts upfront (and that also helps with constrained deserializers).
(The number of things they will have to create, e.g., the number of data items; not the byte size of their representation -- counting bytes here was a mistake RFC 731 and ASN.1 BER shared and that creates much pain in BER.)
With a byte-oriented encoding, counting also happens to require fewer bytes than delimiting for small counts.
So if the serializer is in a position to provide count information in time, we should use it.

CBOR supports streaming by having self-delimited data items -- you can send many of these in sequence for a stream (as in, say, an XMPP-like protocol).

So streaming *of* data items is not a problem with CBOR.
Now let's look at "streaming" *within* a data item.

The actual need for this is a fringe case, but one that is worth looking at.
The only significant use case I know is a state-limited (on-the-fly) converter from a delimited format (such as JSON) to CBOR.
(Unfortunately, that is not just a use case in gateways; using CBOR as a plug-in replacement for JSON may saddle one with an API that makes the CBOR serializer such a converter.)
Putting together an aquarium when being handed fish sticks.

Anything that addresses this specific use case needs to be a hybrid.
(Purely delimited is possible for binary, but tends to be more taxing on the deserializer; it also often requires additional work at the serializer to enable data transparency.)
I tried to avoid designing a hybrid.
Counted is the way things have been moving to in much of CS for the last 10, 15 years.

As you say, delimiters (push/pop, or maybe some form of continuation scheme) can be easily hacked into CBOR, the only victim being its architecture.
Should we?

Grüße, Carsten