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


COMMENTS

author: Natasha Sullivan
date: 2017-10-11 04:55:09.251000000

Uploaded patch set 2: Commit message was updated.

-------------------------------------
author: Hugo Blankenship
date: 2017-10-11 04:55:18.952000000

Patch Set 2:

Build Started http://sdkbuilds.sc.couchbase.com/job/couchbase-java-client-test/219/

-------------------------------------
author: Hugo Blankenship
date: 2017-10-11 04:56:07.698000000

Patch Set 2: Verified+1

Build Successful 

http://sdkbuilds.sc.couchbase.com/job/couchbase-java-client-test/219/ : SUCCESS

-------------------------------------
author: Carmen Buckley
date: 2017-10-11 05:47:01.930000000

Patch Set 2: Code-Review+2

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

Patch Set 2: Verified+1

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