Package io.grpc.netty

Class NettyWritableBufferAllocator

java.lang.Object
io.grpc.netty.NettyWritableBufferAllocator
All Implemented Interfaces:
WritableBufferAllocator

class NettyWritableBufferAllocator extends Object implements WritableBufferAllocator
The default allocator for NettyWritableBuffers used by the Netty transport. We set a minimum bound to avoid unnecessary re-allocation for small follow-on writes and to facilitate Netty's caching of buffer objects for small writes. We set an upper-bound to avoid allocations outside of the arena-pool which are orders of magnitude slower. The Netty transport can receive buffers of arbitrary size and will chunk them based on flow-control so there is no transport requirement for an upper bound.

Note: It is assumed that most applications will be using Netty's direct buffer pools for maximum performance.

  • Field Details

    • MIN_BUFFER

      private static final int MIN_BUFFER
      See Also:
    • MAX_BUFFER

      private static final int MAX_BUFFER
      See Also:
    • allocator

      private final io.netty.buffer.ByteBufAllocator allocator
  • Constructor Details

    • NettyWritableBufferAllocator

      NettyWritableBufferAllocator(io.netty.buffer.ByteBufAllocator allocator)
  • Method Details