bufferpool

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package bufferpool provides tiered sync.Pool byte buffer pools to reduce GC pressure in high-throughput paths (PTY output reading, WebSocket writes, stream management). Three tiers: 4KB (small reads), 32KB (medium I/O), 256KB (large data transfers).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(size int) []byte

Get returns a zero-length byte slice with capacity >= size from the appropriate tier pool. The returned slice has length 0 and must be used with append or resliced. Caller MUST call Put when done to return the buffer.

func GetLen

func GetLen(size int) []byte

GetLen returns a byte slice with length == size (not just capacity). Useful for fixed-size read buffers (e.g. reader.Read(buf)). Caller MUST call Put when done.

func Put

func Put(buf []byte)

Put returns a buffer to the appropriate pool tier based on its capacity. Buffers larger than 256KB are discarded (let GC handle oversized allocations). Always zero-lengths the slice before returning so next Get starts clean.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL