After almost 3 weeks of hard work we are happy to announce the release of Netty 4.0.21.Final. This release contains bug-fixes and performance improvements.

This release is fully-compatible with previous netty 4.0.x releases.

Performance improvements

As stated before we did some performance improvements in this release. The following sub-sections show some more details to give a better idea about the impact.

PooledByteBufAllocator improvements

When using PooledByteBufAllocator with ThreadLocal cache disabled you will see some nice performance boost when allocate buffers > pageSize (which is 8196 bytes by default). Thanks to @pavanka (Facebook) for the contribution.

Last release (4.0.20.Final):

Benchmark (size) Mode Samples Score Score error Units i.n.m.b.ByteBufAllocatorBenchmark.pooledDirectAllocAndFree 16384 thrpt 20 459.932 5.411 ops/ms i.n.m.b.ByteBufAllocatorBenchmark.pooledDirectAllocAndFree 65536 thrpt 20 958.501 4.929 ops/ms i.n.m.b.ByteBufAllocatorBenchmark.pooledHeapAllocAndFree 16384 thrpt 20 460.085 5.020 ops/ms i.n.m.b.ByteBufAllocatorBenchmark.pooledHeapAllocAndFree 65536 thrpt 20 953.632 6.285 ops/ms

This release (4.0.21.Final):

Benchmark (size) Mode Samples Score Score error Units i.n.m.b.ByteBufAllocatorBenchmark.pooledDirectAllocAndFree 16384 thrpt 20 2890.818 32.091 ops/ms i.n.m.b.ByteBufAllocatorBenchmark.pooledDirectAllocAndFree 65536 thrpt 20 2953.811 18.865 ops/ms i.n.m.b.ByteBufAllocatorBenchmark.pooledHeapAllocAndFree 16384 thrpt 20 2889.210 20.680 ops/ms i.n.m.b.ByteBufAllocatorBenchmark.pooledHeapAllocAndFree 65536 thrpt 20 2957.992 61.097 ops/ms

For more details on this change see (#2582).

Recycler improvements

The old Recycler implementation was rewritten to be a lot faster. Thanks again to @belliothsmith (Datastax) for the contribution.

Last release (4.0.20.Final):

Benchmark (size) Mode Samples Score Score error Units i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 00000 thrpt 20 116026994.130 2763381.305 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 00256 thrpt 20 110823170.627 3007221.464 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 01024 thrpt 20 118290272.413 7143962.304 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 04096 thrpt 20 120560396.523 6483323.228 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 16384 thrpt 20 114726607.428 2960013.108 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 65536 thrpt 20 119385917.899 3172913.684 ops/s

This release (4.0.21.Final):

Benchmark (size) Mode Samples Score Score error Units i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 00000 thrpt 20 204158855.315 5031432.145 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 00256 thrpt 20 205179685.861 1934137.841 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 01024 thrpt 20 209906801.437 8007811.254 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 04096 thrpt 20 214288320.053 6413126.689 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 16384 thrpt 20 215940902.649 7837706.133 ops/s i.n.m.i.RecyclableArrayListBenchmark.recycleSameThread 65536 thrpt 20 211141994.206 5017868.542 ops/s

For more details on this change see (#2570).

For more details on changes please refer to the next sections.

Most important changes / fixes

Epoll transport may cause StackOverflow when write many buffers via writev(...) (#2623)

Missing ensureAccessible() may cause SEGFAULT the JVM (#2622)

Could not find class 'sun.misc.Cleaner' on android (#2604)

Could not find class 'sun.nio.ch.DirectBuffer' on android (#2599)

Fix integer overflow in HttpObjectEncoder when write chunk > Integer.MAX (#2592)

Write to LITTLE_ENDIAN buffer in encoder is broken (#2587)

Inconsistent Little Endian Buffer Contents in 4.0.20.Final When Unsafe Enabled (#2580)

Optimize PoolChunk to not use DFS (#2582)

Faster Recycler implementation (#2570)

Provide a proper way to remove thread-local variables (#2578)

Visit here for the complete list of the changes.

As always please let us know if you find any issues. We love feedback!

Thank You

Every idea and bug-report counts and so we thought it is worth mentioning those who helped in this area. Please report an unintended omission.