MCPcopy
hub / github.com/grpc/grpc-go / BinaryTieredBufferPool

Struct BinaryTieredBufferPool

internal/mem/buffer_pool.go:52–65  ·  view source on GitHub ↗

BinaryTieredBufferPool is a buffer pool that uses multiple sub-pools with power-of-two sizes.

Source from the content-addressed store, hash-verified

50// BinaryTieredBufferPool is a buffer pool that uses multiple sub-pools with
51// power-of-two sizes.
52type BinaryTieredBufferPool struct {
53 // exponentToNextLargestPoolMap maps a power-of-two exponent (e.g., 12 for
54 // 4KB) to the index of the next largest sizedBufferPool. This is used by
55 // Get() to find the smallest pool that can satisfy a request for a given
56 // size.
57 exponentToNextLargestPoolMap []int
58 // exponentToPreviousLargestPoolMap maps a power-of-two exponent to the
59 // index of the previous largest sizedBufferPool. This is used by Put()
60 // to return a buffer to the most appropriate pool based on its capacity.
61 exponentToPreviousLargestPoolMap []int
62 sizedPools []bufferPool
63 fallbackPool bufferPool
64 maxPoolCap int // Optimization: Cache max capacity
65}
66
67// NewBinaryTieredBufferPool returns a BufferPool backed by multiple sub-pools.
68// This structure enables O(1) lookup time for Get and Put operations.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected