pool

package
v0.7.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 1 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pool provides a size-class byte buffer pool that eliminates allocations on media-heavy hot paths (audio chunks, image tiles, video frames).

Under millions of concurrent LLM calls the GC cost of per-frame []byte allocations dominates. BytePool provides O(1) amortised Get/Put with no per-operation heap allocation.

Index

Constants

This section is empty.

Variables

View Source
var DefaultBytePool = NewBytePool()

DefaultBytePool is the process-wide byte pool. Providers and processors should use this unless they need isolation.

Functions

This section is empty.

Types

type BytePool

type BytePool struct {
	// contains filtered or unexported fields
}

BytePool is a size-class byte buffer pool.

Usage:

buf := pool.DefaultBytePool.Get(frameSize)
copy(buf, rawPayload)
// ... after consumer is done:
pool.DefaultBytePool.Put(buf)

func NewBytePool

func NewBytePool() *BytePool

NewBytePool creates a new BytePool with pre-allocated size classes.

func (*BytePool) Get

func (p *BytePool) Get(size int) []byte

Get returns a byte slice with len=size from the appropriate size class. The returned slice may have capacity > size.

func (*BytePool) Put

func (p *BytePool) Put(b []byte)

Put returns a byte slice to the pool. After Put, the caller must not reference the slice. Slices larger than the large class are dropped (GC collects them).

Jump to

Keyboard shortcuts

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