Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 275EE957 for ; Wed, 11 Nov 2015 18:35:03 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 00CD117E for ; Wed, 11 Nov 2015 18:35:01 +0000 (UTC) Received: by pacdm15 with SMTP id dm15so37874155pac.3 for ; Wed, 11 Nov 2015 10:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=/ndXU2+4n8v32b8XHGp21IV1WKuu4x8wGLjQjTyO+f8=; b=AFSn4WB0GDpjKbT02ws28r+IpdwE44ed+cs7Kz54z/GimNf7xI+e20PBxxtddhuZT8 KUVdDBf388FZXmjfY33iHIfaMGlFqXxwugdnjuWDZ0NC6/6jGeYM/m3lpTfLSekkmxOY yoQLTA9/4ScXQSEGhsvSCk2ajOploymNc5zluWtohyBndIMxLCSGSPc7i2nNjlJ6uncj o25B+C6AFjvr9TrRZXnHxV/CKOYFHVpw9BAo+jdolBk00pnJRPh4pBXh/HBTGt1q540a F/alcYcnTUS7JSBCF7IC1wTwytp0ndpYpgKJ2jaMkrayLsTZUO15rXNlZROoG6gLH/ed WaJw== X-Received: by 10.67.22.66 with SMTP id hq2mr16255414pad.81.1447266901632; Wed, 11 Nov 2015 10:35:01 -0800 (PST) Received: from [192.168.0.132] (S0106bcd165303d84.cc.shawcable.net. [96.54.102.88]) by smtp.googlemail.com with ESMTPSA id j12sm10566138pbq.55.2015.11.11.10.35.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2015 10:35:01 -0800 (PST) To: bitcoin-dev@lists.linuxfoundation.org References: <5640F172.3010004@gmail.com> <20151109210449.GE5886@mcelrath.org> <5642172C.701@gmail.com> From: Peter Tschipper X-Enigmail-Draft-Status: N1110 Message-ID: <56438A55.2010604@gmail.com> Date: Wed, 11 Nov 2015 10:35:01 -0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------040505020703050008030503" X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: Re: [bitcoin-dev] request BIP number for: "Support for Datastream Compression" X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Development Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Nov 2015 18:35:03 -0000 This is a multi-part message in MIME format. --------------040505020703050008030503 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Here are the latest results on compression ratios for the first 295,000 blocks, compressionlevel=6. I think there are more than enough datapoints for statistical significance. Results are very much similar to the previous test. I'll work on getting a comparison between how much time savings/loss in time there is when syncing the blockchains: compressed vs uncompressed. Still, I think it's clear that serving up compressed blocks, at least historical blocks, will be of benefit for those that have bandwidth caps on their internet connections. The proposal, so far is fairly simple: 1) compress blocks with some compression library: currently zlib but I can investigate other possiblities 2) As a fall back we need to advertise compression as a service. That way we can turn off compression AND decompression completely if needed. 3) Do the compression at the datastream level in the code. CDataStream is the obvious place. Test Results: range = block size range ubytes = average size of uncompressed blocks cbytes = average size of compressed blocks ctime = average time to compress dtime = average time to decompress cmp_ratio% = compression ratio datapoints = number of datapoints taken range ubytes cbytes ctime dtime cmp_ratio% datapoints 0-250b 215 189 0.001 0.000 12.40 91280 250-500b 438 404 0.001 0.000 7.85 13217 500-1KB 761 701 0.001 0.000 7.86 11434 1KB-10KB 4149 3547 0.001 0.000 14.51 52180 10KB-100KB 41934 32604 0.005 0.001 22.25 82890 100KB-200KB 146303 108080 0.016 0.001 26.13 29886 200KB-300KB 243299 179281 0.025 0.002 26.31 25066 300KB-400KB 344636 266177 0.036 0.003 22.77 4956 400KB-500KB 463201 356862 0.046 0.004 22.96 3167 500KB-600KB 545123 429854 0.056 0.005 21.15 366 600KB-700KB 647736 510931 0.065 0.006 21.12 254 700KB-800KB 746540 587287 0.073 0.008 21.33 294 800KB-900KB 868121 682650 0.087 0.008 21.36 199 900KB-1MB 945747 726307 0.091 0.010 23.20 304 On 10/11/2015 8:46 AM, Jeff Garzik via bitcoin-dev wrote: > Comments: > > 1) cblock seems a reasonable way to extend the protocol. Further > wrapping should probably be done at the stream level. > > 2) zlib has crappy security track record. > > 3) A fallback path to non-compressed is required, should compression > fail or crash. > > 4) Most blocks and transactions have runs of zeroes and/or highly > common bit-patterns, which contributes to useful compression even at > smaller sizes. Peter Ts's most recent numbers bear this out. zlib > has a dictionary (32K?) which works well with repeated patterns such > as those you see with concatenated runs of transactions. > > 5) LZO should provide much better compression, at a cost of CPU > performance and using a less-reviewed, less-field-tested library. > > > > > > On Tue, Nov 10, 2015 at 11:30 AM, Tier Nolan via bitcoin-dev > > wrote: > > > > On Tue, Nov 10, 2015 at 4:11 PM, Peter Tschipper > > wrote: > > There are better ways of sending new blocks, that's certainly > true but for sending historical blocks and seding transactions > I don't think so. This PR is really designed to save > bandwidth and not intended to be a huge performance > improvement in terms of time spent sending. > > > If the main point is for historical data, then sticking to just > blocks is the best plan. > > Since small blocks don't compress well, you could define a > "cblocks" message that handles multiple blocks (just concatenate > the block messages as payload before compression). > > The sending peer could combine blocks so that each cblock is > compressing at least 10kB of block data (or whatever is optimal). > It is probably worth specifying a maximum size for network buffer > reasons (either 1MB or 1 block maximum). > > Similarly, transactions could be combined together and compressed > "ctxs". The inv messages could be modified so that you can > request groups of 10-20 transactions. That would depend on how > much of an improvement compressed transactions would represent. > > More generally, you could define a message which is a compressed > message holder. That is probably to complex to be worth the > effort though. > > > >> >> On Tue, Nov 10, 2015 at 5:40 AM, Johnathan Corgan via >> bitcoin-dev > > wrote: >> >> On Mon, Nov 9, 2015 at 5:58 PM, gladoscc via bitcoin-dev >> > > wrote: >> >> >> I think 25% bandwidth savings is certainly >> considerable, especially for people running full >> nodes in countries like Australia where internet >> bandwidth is lower and there are data caps. >> >> >> ​ This reinforces the idea that such trade-off decisions >> should be be local and negotiated between peers, not a >> required feature of the network P2P.​ >> >> >> -- >> Johnathan Corgan >> Corgan Labs - SDR Training and Development Services >> http://corganlabs.com >> >> _______________________________________________ >> bitcoin-dev mailing list >> bitcoin-dev@lists.linuxfoundation.org >> >> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev >> >> >> >> >> _______________________________________________ >> bitcoin-dev mailing list >> bitcoin-dev@lists.linuxfoundation.org >> >> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev > > > > _______________________________________________ > bitcoin-dev mailing list > bitcoin-dev@lists.linuxfoundation.org > > https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev > > > > > _______________________________________________ > bitcoin-dev mailing list > bitcoin-dev@lists.linuxfoundation.org > https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev --------------040505020703050008030503 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Here are the latest results on compression ratios for the first 295,000 blocks, compressionlevel=6.  I think there are more than enough datapoints for statistical significance. 

Results are very much similar to the previous test.   I'll work on getting a comparison between how much time savings/loss in time there is when syncing the blockchains: compressed vs uncompressed.  Still, I think it's clear that serving up compressed blocks, at least historical blocks, will be of benefit for those that have bandwidth caps on their internet connections.

The proposal, so far is fairly simple:
1) compress blocks with some compression library: currently zlib but I can investigate other possiblities
2) As a fall back we need to advertise compression as a service.  That way we can turn off compression AND decompression completely if needed.
3) Do the compression at the datastream level in the code.  CDataStream is the obvious place.


Test Results:

range = block size range
ubytes = average size of uncompressed blocks
cbytes = average size of compressed blocks
ctime = average time to compress
dtime = average time to decompress
cmp_ratio% = compression ratio
datapoints = number of datapoints taken

range       ubytes    cbytes    ctime    dtime    cmp_ratio%    datapoints
0-250b      215            189    0.001    0.000    12.40             91280
250-500b    438            404    0.001    0.000    7.85             13217
500-1KB     761            701    0.001    0.000    7.86               11434
1KB-10KB    4149    3547    0.001    0.000      14.51             52180
10KB-100KB  41934    32604    0.005    0.001    22.25         82890
100KB-200KB 146303    108080    0.016    0.001    26.13    29886
200KB-300KB 243299    179281    0.025    0.002    26.31    25066
300KB-400KB 344636    266177    0.036    0.003    22.77    4956
400KB-500KB 463201    356862    0.046    0.004    22.96    3167
500KB-600KB 545123    429854    0.056    0.005    21.15    366
600KB-700KB 647736    510931    0.065    0.006    21.12    254
700KB-800KB 746540    587287    0.073    0.008    21.33    294
800KB-900KB 868121    682650    0.087    0.008    21.36    199
900KB-1MB   945747    726307    0.091    0.010    23.20    304

On 10/11/2015 8:46 AM, Jeff Garzik via bitcoin-dev wrote:
Comments:

1) cblock seems a reasonable way to extend the protocol.  Further wrapping should probably be done at the stream level.

2) zlib has crappy security track record.

3) A fallback path to non-compressed is required, should compression fail or crash.

4) Most blocks and transactions have runs of zeroes and/or highly common bit-patterns, which contributes to useful compression even at smaller sizes.  Peter Ts's most recent numbers bear this out.  zlib has a dictionary (32K?) which works well with repeated patterns such as those you see with concatenated runs of transactions.

5) LZO should provide much better compression, at a cost of CPU performance and using a less-reviewed, less-field-tested library.





On Tue, Nov 10, 2015 at 11:30 AM, Tier Nolan via bitcoin-dev <bitcoin-dev@lists.linuxfoundation.org> wrote:


On Tue, Nov 10, 2015 at 4:11 PM, Peter Tschipper <peter.tschipper@gmail.com> wrote:
There are better ways of sending new blocks, that's certainly true but for sending historical blocks and seding transactions I don't think so.  This PR is really designed to save bandwidth and not intended to be a huge performance improvement in terms of time spent sending.

If the main point is for historical data, then sticking to just blocks is the best plan.

Since small blocks don't compress well, you could define a "cblocks" message that handles multiple blocks (just concatenate the block messages as payload before compression). 

The sending peer could combine blocks so that each cblock is compressing at least 10kB of block data (or whatever is optimal).  It is probably worth specifying a maximum size for network buffer reasons (either 1MB or 1 block maximum).

Similarly, transactions could be combined together and compressed "ctxs".  The inv messages could be modified so that you can request groups of 10-20 transactions.  That would depend on how much of an improvement compressed transactions would represent.

More generally, you could define a message which is a compressed message holder.  That is probably to complex to be worth the effort though.

 

On Tue, Nov 10, 2015 at 5:40 AM, Johnathan Corgan via bitcoin-dev <bitcoin-dev@lists.linuxfoundation.org> wrote:
On Mon, Nov 9, 2015 at 5:58 PM, gladoscc via bitcoin-dev <bitcoin-dev@lists.linuxfoundation.org> wrote:
 
I think 25% bandwidth savings is certainly considerable, especially for people running full nodes in countries like Australia where internet bandwidth is lower and there are data caps.

​ This reinforces the idea that such trade-off decisions should be be local and negotiated between peers, not a required feature of the network P2P.​
 

--
Johnathan Corgan
Corgan Labs - SDR Training and Development Services

_______________________________________________
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev




_______________________________________________
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev



_______________________________________________
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev




_______________________________________________
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev

--------------040505020703050008030503--