Re: [core] progressing ietf-core-yang-cbor and ietf-core-sid

Carsten Bormann <cabo@tzi.org> Wed, 15 January 2020 17:07 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: core@ietfa.amsl.com
Delivered-To: core@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 98075120892 for <core@ietfa.amsl.com>; Wed, 15 Jan 2020 09:07:27 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.2
X-Spam-Level:
X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
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 0YdfA3Ji_8ws for <core@ietfa.amsl.com>; Wed, 15 Jan 2020 09:07:23 -0800 (PST)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 02BF6120886 for <core@ietf.org>; Wed, 15 Jan 2020 09:07:23 -0800 (PST)
Received: from [192.168.217.119] (p548DC4D8.dip0.t-ipconnect.de [84.141.196.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 47yYfK1d2Dz160Y; Wed, 15 Jan 2020 18:07:21 +0100 (CET)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <MN2PR11MB43663281BBACA171BEBFAB2BB5370@MN2PR11MB4366.namprd11.prod.outlook.com>
Date: Wed, 15 Jan 2020 18:07:20 +0100
Cc: Michael Richardson <mcr+ietf@sandelman.ca>, "core@ietf.org" <core@ietf.org>
X-Mao-Original-Outgoing-Id: 600800839.819038-4f318758cdb42ffd7197019f411ea784
Content-Transfer-Encoding: quoted-printable
Message-Id: <B7600D51-B3A9-44F7-A7E4-E9D6CD496246@tzi.org>
References: <29380.1565102380@localhost> <BL0PR06MB50428065032ECC2AB3345F619AD70@BL0PR06MB5042.namprd06.prod.outlook.com> <7505.1565633977@localhost> <BL0PR06MB50424C618A704460E4A8F8D99AA90@BL0PR06MB5042.namprd06.prod.outlook.com> <18990.1577231446@localhost> <CAJFkdRyWOfCb4U09rEJ-ZMR3GUuk-rmQ+f3Fs164Mxs8qkeVuw@mail.gmail.com> <22612.1578626081@localhost> <CAJFkdRztFUxdGcdvtTgB=9c-e_BwDAgLTmVPJ+OB8-dgs1sGog@mail.gmail.com> <15754.1578789013@localhost> <CAJFkdRy_3pC37ZxzhTmzqRgWjwDvEFTuhu5Z8+_ktaJgoeOGfg@mail.gmail.com> <6025.1578939111@localhost> <ACA7E58F-A308-457B-846F-E298807DCEC1@tzi.org> <MN2PR11MB4366A026E4A16F311E5922BFB5370@MN2PR11MB4366.namprd11.prod.outlook.com> <46BA6719-5319-40FC-B218-5832F32C85BC@tzi.org> <MN2PR11MB43663281BBACA171BEBFAB2BB5370@MN2PR11MB4366.namprd11.prod.outlook.com>
To: "Rob Wilton (rwilton)" <rwilton@cisco.com>
X-Mailer: Apple Mail (2.3608.40.2.2.4)
Archived-At: <https://mailarchive.ietf.org/arch/msg/core/u6FC0L7LAnlHjIGNVqWByUFTmnU>
Subject: Re: [core] progressing ietf-core-yang-cbor and ietf-core-sid
X-BeenThere: core@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Constrained RESTful Environments \(CoRE\) Working Group list" <core.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/core>, <mailto:core-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/core/>
List-Post: <mailto:core@ietf.org>
List-Help: <mailto:core-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/core>, <mailto:core-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 15 Jan 2020 17:07:27 -0000

OK, let’s get pedantic then.

The operation that would be needed here without the 63-bit restriction is adding a 65-bit signed (delta) to a 64-bit unsigned (context SID), with the constraint that the result (actual SID) fits into a 64-bit unsigned.  Unless you want to do error checking (which probably is a good idea), this can be done entirely with 64-bit unsigned numbers, simply ignoring the modulo wraparounds.  Error checking then just requires a few magnitude checks, which do require some scribbling on the back of an envelope to get right.  All CPU architectures of the last 40 years (OK, maybe since the iAPX 432, which was 1981) that I know of make it not hard to do these things.  Platforms like the JVM do.

CBOR’s "65-bit signed" (64-bit unsigned + sign bit in mt) integer coverage is indeed surprising initially (it is until you start to embrace bignums).  From the C language, implementers should be used to the fact that as soon as you go to "signed 64-bit" (63-bit unsigned + sign bit expressed as two’s complement), there are all kinds of problems.  Of course, not all C courses teach this…  (The main problem being that 64-bit is big enough that many implementers never reach the boundaries of this space.)

So the problem here really is in the platform or BKAC (between keyboard and chair), not in the architecture...

Grüße, Carsten


> On 2020-01-15, at 17:40, Rob Wilton (rwilton) <rwilton@cisco.com> wrote:
> 
>  
>  
> > -----Original Message-----
> > From: Carsten Bormann <cabo@tzi.org>
> > Sent: 15 January 2020 15:46
> > To: Rob Wilton (rwilton) <rwilton@cisco.com>
> > Cc: Michael Richardson <mcr+ietf@sandelman.ca>; core@ietf.org
> > Subject: Re: [core] progressing ietf-core-yang-cbor and ietf-core-sid
> >
> > Yeah, but here the problem is in the head of the implementor and not in
> > the CPU architecture :-)
>  
> I'm not sure that I agree, 😉
>  
> I might be wrong, but most CPU architectures don't support 64 bit negative values (unless you move to 128 bit signed numbers with the corresponding performance overhead).  Of course, implementors can work around the architecture limitations by emulating 64 bit negative numbers using unsigned 64 bit numbers ... 
>  
>  
> In fact, I was wondering whether it is really a good thing that CBOR allows a 64 bit negative integer to be expressed.  It means that the CBOR encoding can easily carry values that most implementations cannot easily generate or represent.
>  
> So, I looked at the first available C implementation example at https://cbor.io/impls.html, and it can't handle negative 64 bit numbers, overflowing them into a long variable.  I wonder what proportion of CBOR implementations do handle these correctly ...  Of course, I'm not suggesting changing the spec, just a retrospective observation.
>  
> > I was not suggesting the text behind the
> > substitutes to be included, this was just explanation why I’d like to have
> > the change.
> [RW] 
> Yes, but I think that "architectures" is probably the correct term here, at least until we end up with CPUs with a 65 bit signed datapath, although I have to confess that I doubt that the choice of word really matters. 😊
>  
> Thanks,
> Rob
>  
>  
>  
> >
> > Grüße, Carsten
> >
> >
> > > On 2020-01-15, at 16:01, Rob Wilton (rwilton) <rwilton@cisco.com> wrote:
> > >
> > >
> > >
> > >> -----Original Message-----
> > >> From: core <core-bounces@ietf.org> On Behalf Of Carsten Bormann
> > >> Sent: 15 January 2020 13:35
> > >> To: Michael Richardson <mcr+ietf@sandelman.ca>
> > >> Cc: core@ietf.org
> > >> Subject: Re: [core] progressing ietf-core-yang-cbor and ietf-core-sid
> > >>
> > >> (No chair hat.)
> > >>
> > >> On 2020-01-13, at 19:11, Michael Richardson <mcr+ietf@sandelman.ca>
> > wrote:
> > >>>
> > >>> The use of 63-bit unsigned integers allows SIDs to be manipulated
> > >>> more easily  on architectures that might otherwise lack native
> > >>> 64-bit
> > >> unsigned arithmetic.
> > >>> The loss a single bit of precision is not significant given the size
> > >>> of the  space.
> > >>
> > >> s/use of/limitation to/     (we have been using them before)
> > >> s/architectures/platforms/  (Java is our main problem here, no?)
> > > [RW]
> > > I think that it would be awkward for most languages/CPU architectures,
> > anywhere where you could end up with a negative number that is less than
> > 2^63.
> > >
> > > Yes, it is possible to write code in C or Java to handle this, but my
> > > hunch is that implementations could easily get this wrong (e.g. by
> > > just using signed int64 as the type to hold the difference between
> > > parent and child SIDs.)
> > >
> > > Thanks,
> > > Rob
> > >
> > >
> > >> s/precision/range/ s/space/remaining space/
> > >>
> > >> Grüße, Carsten
> > >>
> > >> _______________________________________________
> > >> core mailing list
> > >> core@ietf.org
> > >> https://www.ietf.org/mailman/listinfo/core