package mem
Import Path
google.golang.org/grpc/internal/mem (on go.dev)
Dependency Relation
imports 5 packages, and imported by 2 packages
Involved Source Files
Package mem provides utilities that facilitate memory reuse in byte slices
that are used as buffers.
Package-Level Type Names (total 6, in which 4 are exported)
BinaryTieredBufferPool is a buffer pool that uses multiple sub-pools with
power-of-two sizes.
exponentToNextLargestPoolMap maps a power-of-two exponent (e.g., 12 for
4KB) to the index of the next largest sizedBufferPool. This is used by
Get() to find the smallest pool that can satisfy a request for a given
size.
exponentToPreviousLargestPoolMap maps a power-of-two exponent to the
index of the previous largest sizedBufferPool. This is used by Put()
to return a buffer to the most appropriate pool based on its capacity.
fallbackPool bufferPool
// Optimization: Cache max capacity
sizedPools []bufferPool
Get returns a buffer with specified length from the pool.
Put returns a buffer to the pool.
(*BinaryTieredBufferPool) poolForGet(size int) bufferPool
(*BinaryTieredBufferPool) poolForPut(bCap int) bufferPool
*BinaryTieredBufferPool : google.golang.org/grpc/mem.BufferPool
*BinaryTieredBufferPool : bufferPool
func NewBinaryTieredBufferPool(powerOfTwoExponents ...uint8) (*BinaryTieredBufferPool, error)
func NewDirtyBinaryTieredBufferPool(powerOfTwoExponents ...uint8) (*BinaryTieredBufferPool, error)
func newBinaryTiered(sizedPoolFactory func(int) bufferPool, fallbackPool bufferPool, powerOfTwoExponents ...uint8) (*BinaryTieredBufferPool, error)
NopBufferPool is a buffer pool that returns new buffers without pooling.
Get returns a buffer with specified length from the pool.
Put returns a buffer to the pool.
NopBufferPool : google.golang.org/grpc/mem.BufferPool
NopBufferPool : bufferPool
SimpleBufferPool is an implementation of the mem.BufferPool interface that
attempts to pool buffers with a sync.Pool. When Get is invoked, it tries to
acquire a buffer from the pool but if that buffer is too small, it returns it
to the pool and creates a new one.
pool sync.Pool
shouldZero bool
Get returns a buffer with specified length from the pool.
Put returns a buffer to the pool.
*SimpleBufferPool : google.golang.org/grpc/mem.BufferPool
*SimpleBufferPool : bufferPool
func NewDirtySimplePool() *SimpleBufferPool
func google.golang.org/grpc/internal/transport.ioBufferPool(size int) *SimpleBufferPool
func google.golang.org/grpc/internal/transport.newBufWriter(conn io.Writer, batchSize int, pool *SimpleBufferPool) *transport.bufWriter
TieredBufferPool implements the BufferPool interface with multiple tiers of
buffer pools for different sizes of buffers.
fallbackPool SimpleBufferPool
sizedPools []*sizedBufferPool
Get returns a buffer with specified length from the pool.
Put returns a buffer to the pool.
(*TieredBufferPool) getPool(size int) bufferPool
*TieredBufferPool : google.golang.org/grpc/mem.BufferPool
*TieredBufferPool : bufferPool
func NewTieredBufferPool(poolSizes ...int) *TieredBufferPool
Package-Level Functions (total 6, in which 4 are exported)
NewBinaryTieredBufferPool returns a BufferPool backed by multiple sub-pools.
This structure enables O(1) lookup time for Get and Put operations.
The arguments provided are the exponents for the buffer capacities (powers
of 2), not the raw byte sizes. For example, to create a pool of 16KB buffers
(2^14 bytes), pass 14 as the argument.
NewDirtyBinaryTieredBufferPool returns a BufferPool backed by multiple
sub-pools. It is similar to NewBinaryTieredBufferPool but it does not
initialize the buffers before returning them.
NewDirtySimplePool constructs a [SimpleBufferPool]. It does not initialize
the buffers before returning them. Callers must ensure they don't read the
buffers before writing data to them.
NewTieredBufferPool returns a BufferPool implementation that uses multiple
underlying pools of the given pool sizes.
Package-Level Variables (only one, which is unexported)
Package-Level Constants (only one, which is unexported)
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64)