From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 9AACE98C for ; Fri, 9 Jun 2017 03:43:14 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f172.google.com (mail-yw0-f172.google.com [209.85.161.172]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C1F4CFD for ; Fri, 9 Jun 2017 03:43:10 +0000 (UTC) Received: by mail-yw0-f172.google.com with SMTP id e142so9946064ywa.1 for ; Thu, 08 Jun 2017 20:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=74umXgYXMAGH5ztwaUB6yNo0TXfvEPPIaMW0UpAScRc=; b=IiyKNQF4s0q05bupPPyQ0nIR3fDETim+3HRV0/HU6bW4ZYnPxaD0OfYeP2BiXd6UYd 9RKSSgTOr7MzjEiKwspjNacXpxgXXo4eJhu0B8mW7Rtg8pMaZctWc/bFtxviR8od5nyT UYMABMrdCb/RA0Lb0+moQ9l7daFYlisV2FyhaQhNU3C2SAig7TEWS6REfAJflty9SQtq T3FGgiTkvWw4nSrqs/cPYkWoOFWrjVO2/jnf2UF4cxc2xinrZMc9NKeh2CUEQH851K3i qds8WBsqcAHHchEy3+HMUplmtKSCqnqqMyKkrhzPEwVs37t7eB/X01P9akji9PNmhhX6 fxog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=74umXgYXMAGH5ztwaUB6yNo0TXfvEPPIaMW0UpAScRc=; b=un4TtlsMH8Nh9p3W5JaCtHm+jsAodt3FZvxQ+dE3QE8KISHdoxnp4I45x5Ot0BbHsD lm/pWanrKm4p00tFCpKxQK1V8Sy+Nly56yfzgjallaZFkgQKoL0gKhYWdvEX1saUO2Y3 LKSm9scYyJQldTZtWR220hunP5i+Jv3SGiP3CQWpbw10Lv/lIz6YCkT6egsKF/YZ4V6D NRAVFqsPSocmOt6Jxl4UizD6wRMup6A/qNRrMC+ftSHLTY2uK6JoC/CF2Dj+69aDifvZ yU4w/zC6BobmFYRS8qP2QTZfRRYCvpsXuunkDH4nnJgDPqafu+2em4d6uxZ+/f8SGkk8 a86A== X-Gm-Message-State: AODbwcBLtVqVaO7GE2N+UaHq/Ociiz9QWBSYWdzfX5N4LWyIS7Pf0/Be 66r8mEZoPROTtdUVLbFvyGpx+xioVkrn X-Received: by 10.129.155.137 with SMTP id s131mr521837ywg.124.1496979789894; Thu, 08 Jun 2017 20:43:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Olaoluwa Osuntokun Date: Fri, 09 Jun 2017 03:42:58 +0000 Message-ID: To: Gregory Maxwell Content-Type: multipart/alternative; boundary="94eb2c0b927c9cdc6b05517ec449" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Arnoud Kouwenhoven - Pukaki Corp via bitcoin-dev Subject: Re: [bitcoin-dev] BIP Proposal: Compact Client Side Filtering for Light Clients X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jun 2017 03:43:14 -0000 --94eb2c0b927c9cdc6b05517ec449 Content-Type: text/plain; charset="UTF-8" Gregory wrote: > I see the inner loop of construction and lookup are free of > non-constant divmod. This will result in implementations being > needlessly slow Ahh, sipa brought this up other day, but I thought he was referring to the coding loop (which uses a power of 2 divisor/modulus), not the siphash-then-reduce loop. > I believe this can be fixed by using this approach > http://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/ > which has the same non-uniformity as mod but needs only a multiply and > shift. Very cool, I wasn't aware of the existence of such a mapping. Correct me if I'm wrong, but from my interpretation we can't use that method as described as we need to output 64-bit integers rather than 32-bit integers. A range of 32-bits would be constrain the number of items we could encode to be ~4096 to ensure that we don't overflow with fp values such as 20 (which we currently use in our code). If filter commitment are to be considered for a soft-fork in the future, then we should definitely optimize the construction of the filters as much as possible! I'll look into that paper you referenced to get a feel for just how complex the optimization would be. > Shouldn't all cases in your spec where you have N=transactions be > n=indexed-outputs? Otherwise, I think your golomb parameter and false > positive rate are wrong. Yep! Nice catch. Our code is correct, but mistake in the spec was an oversight on my part. I've pushed a commit[1] to the bip repo referenced in the OP to fix this error. I've also pushed another commit to explicitly take advantage of the fact that P is a power-of-two within the coding loop [2]. -- Laolu [1]: https://github.com/Roasbeef/bips/commit/bc5c6d6797f3df1c4a44213963ba12e72122163d [2]: https://github.com/Roasbeef/bips/commit/578a4e3aa8ec04524c83bfc5d14be1b2660e7f7a On Wed, Jun 7, 2017 at 2:41 PM Gregory Maxwell wrote: > On Thu, Jun 1, 2017 at 7:01 PM, Olaoluwa Osuntokun via bitcoin-dev > wrote: > > Hi y'all, > > > > Alex Akselrod and I would like to propose a new light client BIP for > > consideration: > > * > https://github.com/Roasbeef/bips/blob/master/gcs_light_client.mediawiki > > I see the inner loop of construction and lookup are free of > non-constant divmod. This will result in implementations being > needlessly slow (especially on arm, but even on modern x86_64 a > division is a 90 cycle-ish affair.) > > I believe this can be fixed by using this approach > > http://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/ > which has the same non-uniformity as mod but needs only a multiply > and shift. > > Otherwise fast implementations will have to implement the code to > compute bit twiddling hack exact division code, which is kind of > complicated. (e.g. via the technique in "{N}-bit Unsigned Division via > {N}-bit Multiply-Add" by Arch D. Robison). > > Shouldn't all cases in your spec where you have N=transactions be > n=indexed-outputs? Otherwise, I think your golomb parameter and false > positive rate are wrong. > --94eb2c0b927c9cdc6b05517ec449 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Gregory wrote:
> I see the inner loop of= construction and lookup are free of
> non-constant divmod. Th= is will result in implementations being
> needlessly slow=C2= =A0

Ahh, sipa brought this up other day, but I tho= ught he was referring to the
coding loop (which uses a power of 2= divisor/modulus), not the
siphash-then-reduce loop.
> I believe this can be fixed by using this approach
<= div>> http://lemire.me/blog/2016/06/27/a-fast-alternative-= to-the-modulo-reduction/
> which has the same non-uniformi= ty as mod but needs only a multiply and
> shift.
Very cool, I wasn't aware of the existence of such a mappin= g.

Correct me if I'm wrong, but from my interp= retation we can't use that
method as described as we need to = output 64-bit integers rather than
32-bit integers. A range of 32= -bits would be constrain the number of items
we could encode to b= e ~4096 to ensure that we don't overflow with fp
values such = as 20 (which we currently use in our code).

If fil= ter commitment are to be considered for a soft-fork in the future,
then we should definitely optimize the construction of the filters as muc= h
as possible! I'll look into that paper you referenced to ge= t a feel for
just how complex the optimization would be.

> Shouldn't all cases in your spec where you have N= =3Dtransactions be
> n=3Dindexed-outputs? Otherwise, I think y= our golomb parameter and false
> positive rate are wrong.

Yep! Nice catch. Our code is correct, but mistake in t= he spec was an
oversight on my part. I've pushed a commit[1] = to the bip repo referenced
in the OP to fix this error.

I've also pushed another commit to explicitly take adva= ntage of the fact
that P is a power-of-two within the coding loop= [2].

-- Laolu



On Wed, Jun 7, 2= 017 at 2:41 PM Gregory Maxwell <greg@xi= ph.org> wrote:
On Thu, Jun 1= , 2017 at 7:01 PM, Olaoluwa Osuntokun via bitcoin-dev
<bitcoin-dev@lists.linuxfoundation.org> wrote:
> Hi y'all,
>
> Alex Akselrod and I would like to propose a new light client BIP for > consideration:
>=C2=A0 =C2=A0 * https://g= ithub.com/Roasbeef/bips/blob/master/gcs_light_client.mediawiki

I see the inner loop of construction and lookup are free of
non-constant divmod. This will result in implementations being
needlessly slow (especially on arm, but even on modern x86_64 a
division is a 90 cycle-ish affair.)

I believe this can be fixed by using this approach
http://lemire.me/blog/20= 16/06/27/a-fast-alternative-to-the-modulo-reduction/
=C2=A0 =C2=A0which has the same non-uniformity as mod but needs only a mult= iply
and shift.

Otherwise fast implementations will have to implement the code to
compute bit twiddling hack exact division code, which is kind of
complicated. (e.g. via the technique in "{N}-bit Unsigned Division via=
{N}-bit Multiply-Add" by Arch D. Robison).

Shouldn't all cases in your spec where you have N=3Dtransactions be
n=3Dindexed-outputs? Otherwise, I think your golomb parameter and false
positive rate are wrong.
--94eb2c0b927c9cdc6b05517ec449--