DESCRIPTION

JCBC-1140: Optimize object decoding from direct byte buffers.

Motivation
----------
When retrieving a document Bucket#get the netty buffer content is
duplicated before the parsing by Jackson, since it is converted from
a direct buffer into a byte array.

Modifications
-------------
Wrap the ByteBuf in an inputstream. Jackson now directly parse the netty
ByteBuf content without having to do an additional memory copy.

Result
------
Reduced memory allocations
YMMV but in our test it was a ~10% reduction

For reference, here are some JMH numbers in comparison:

Heap allocated buffers, 1.5k (small) and 8k (large):

MyBenchmark.oldSmallHeap                                     thrpt   60  217977.270 ± 5312.782   ops/s
MyBenchmark.oldSmallHeap:·gc.alloc.rate                      thrpt   60     778.375 ±   18.909  MB/sec

MyBenchmark.newSmallHeap                                     thrpt   60  213909.924 ± 5349.298   ops/s
MyBenchmark.newSmallHeap:·gc.alloc.rate                      thrpt   60     773.779 ±   19.429  MB/sec

MyBenchmark.oldLargeHeap                                     thrpt   60   34630.505 ±  943.865   ops/s
MyBenchmark.oldLargeHeap:·gc.alloc.rate                      thrpt   60     739.460 ±   20.140  MB/sec

MyBenchmark.newLargeHeap                                     thrpt   60   34262.467 ±  843.218   ops/s
MyBenchmark.newLargeHeap:·gc.alloc.rate                      thrpt   60     731.710 ±   18.065  MB/sec

Direct allocated buffers, 1.5k (small) and 8k (large):

MyBenchmark.oldSmallDirect                                   thrpt   60  207967.868 ± 5460.817   ops/s
MyBenchmark.oldSmallDirect:·gc.alloc.rate                    thrpt   60     961.241 ±   25.313  MB/sec

MyBenchmark.newSmallDirect                                   thrpt   60  211931.986 ± 5505.153   ops/s
MyBenchmark.newSmallDirect:·gc.alloc.rate                    thrpt   60     775.659 ±   20.521  MB/sec

MyBenchmark.newLargeDirect                                   thrpt   60   34800.886 ±  881.995   ops/s
MyBenchmark.newLargeDirect:·gc.alloc.rate                    thrpt   60     744.829 ±   18.824  MB/sec

MyBenchmark.oldLargeDirect                                   thrpt   60   34101.936 ± 1007.703   ops/s
MyBenchmark.oldLargeDirect:·gc.alloc.rate                    thrpt   60     900.992 ±   26.708  MB/sec

Change-Id: I2c215ad0beb05266f49f19874d4673b195695f03
Reviewed-on: http://review.couchbase.org/84255
Tested-by: Hugo Blankenship xxx@xxx.xxx
Reviewed-by: Carmen Buckley xxx@xxx.xxx
Tested-by: Natasha Sullivan xxx@xxx.xxx


COMMENTS

author: Natasha Sullivan
date: 2017-10-11 06:32:42.364000000

Change has been successfully cherry-picked as 90b0c239b671bf4348617c095c1c2e745a4930a4 by Natasha Sullivan

-------------------------------------
