gpu

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Unlicense Imports: 25 Imported by: 0 modules, 0 packages

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

Index

Constants

View Source
const (
	BackendCPU    = types.BackendCPU
	BackendCUDA   = types.BackendCUDA
	BackendMetal  = types.BackendMetal
	BackendOpenCL = types.BackendOpenCL
	BackendTPU    = types.BackendTPU
)

Variables

This section is empty.

Functions

func CheckBinaryDiagnostic

func CheckBinaryDiagnostic(logger *zerolog.Logger)

CheckBinaryDiagnostic verifies if the binary is built with GPU support. Since this file is built without the 'gpu' tag, it checks hardware and warns if GPU capability is wasted.

func DetectAvailableDevices

func DetectAvailableDevices() ([]int32, error)

func GetDeviceCount

func GetDeviceCount() int

func GetGPUFriendlyPtr

func GetGPUFriendlyPtr(data []float32) unsafe.Pointer

func GetGPUFriendlySlice

func GetGPUFriendlySlice(data []float32) []byte

func GetGPURequirements

func GetGPURequirements(backend GPUBackend) (bool, string, error)

GetGPURequirements returns the requirements for GPU acceleration based on backend

func GetGlobalGPUUtilization

func GetGlobalGPUUtilization() (float32, error)

func IsGPUComputeError

func IsGPUComputeError(err error) bool

func IsGPUMemoryError

func IsGPUMemoryError(err error) bool

Error helper re-exports

func KernelProfilingEnabled

func KernelProfilingEnabled() bool

KernelProfilingEnabled reports that nothing is being timed.

func ResetKernelProfile

func ResetKernelProfile()

ResetKernelProfile is a no-op without a CUDA backend.

func SetKernelProfiling

func SetKernelProfiling(bool)

SetKernelProfiling is a no-op without a CUDA backend.

func ValidateBackend

func ValidateBackend(backend GPUBackend) error

ValidateBackend validates if the specified backend is available on the current system

Types

type CPUIndex

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

CPUIndex implements a CPU-only fallback index using linear scan

func NewCPUIndex

func NewCPUIndex(cfg GPUConfig) (*CPUIndex, error)

func (*CPUIndex) Add

func (i *CPUIndex) Add(ids []int64, vectors []float32) error

func (*CPUIndex) AddPQ

func (i *CPUIndex) AddPQ(ids []int64, codes []byte, m int) error

func (*CPUIndex) AddTurboQuant

func (i *CPUIndex) AddTurboQuant(ids []int64, tqData []byte, bitsPerAngle int) error

func (*CPUIndex) AssignToClusters

func (i *CPUIndex) AssignToClusters(vectors []float32, centroids []float32) ([]uint32, error)

func (*CPUIndex) Backend

func (i *CPUIndex) Backend() GPUBackend

func (*CPUIndex) Clear

func (i *CPUIndex) Clear() error

func (*CPUIndex) Close

func (i *CPUIndex) Close() error

func (*CPUIndex) DeviceID

func (i *CPUIndex) DeviceID() int32

func (*CPUIndex) EncodePQ

func (i *CPUIndex) EncodePQ(vectors []float32) ([]byte, error)

func (*CPUIndex) GetDeviceInfo

func (i *CPUIndex) GetDeviceInfo() (*GPUInfo, error)

func (*CPUIndex) GetMemoryInfo

func (i *CPUIndex) GetMemoryInfo() (total, free, used int64, err error)

func (*CPUIndex) GetUtilization

func (i *CPUIndex) GetUtilization() (float32, error)

func (*CPUIndex) GraphExpand

func (i *CPUIndex) GraphExpand(seeds []uint32, depth int, alpha float32) ([]uint32, []float32, error)

func (*CPUIndex) HaversineSearch

func (i *CPUIndex) HaversineSearch(centerLat, centerLon float32, points []float32, earthRadius float32) ([]float32, error)

func (*CPUIndex) NormBatch

func (i *CPUIndex) NormBatch(vectors []float32, dims int) ([]float32, error)

func (*CPUIndex) PruneNeighbors

func (i *CPUIndex) PruneNeighbors(candidateIds []uint32, candidateDists []float32, maxNeighbors int, allVectors []float32) ([]uint32, error)

func (*CPUIndex) Reset

func (i *CPUIndex) Reset() error

func (*CPUIndex) Search

func (i *CPUIndex) Search(vector []float32, k int) (ids []int64, distances []float32, err error)

func (*CPUIndex) SearchBatch

func (i *CPUIndex) SearchBatch(vectors [][]float32, k int) ([][]int64, [][]float32, error)

func (*CPUIndex) SearchBatchDistances

func (i *CPUIndex) SearchBatchDistances(query []float32, candidateIDs []uint32) ([]float32, error)

func (*CPUIndex) SearchComplex64

func (i *CPUIndex) SearchComplex64(vector []uint16, k int) ([]int64, []float32, error)

func (*CPUIndex) SearchComplex128

func (i *CPUIndex) SearchComplex128(vector []float32, k int) ([]int64, []float32, error)

func (*CPUIndex) SearchFloat16

func (i *CPUIndex) SearchFloat16(vector []uint16, k int) ([]int64, []float32, error)

func (*CPUIndex) SearchGreedy

func (i *CPUIndex) SearchGreedy(query []float32, entryPoint uint32, entryDist float32) (uint32, float32, error)

func (*CPUIndex) SearchInt8

func (i *CPUIndex) SearchInt8(vector []int8, k int) ([]int64, []float32, error)

func (*CPUIndex) SearchInt16

func (i *CPUIndex) SearchInt16(vector []int16, k int) ([]int64, []float32, error)

func (*CPUIndex) SearchPQ

func (i *CPUIndex) SearchPQ(lookupTable []float32, m int, k int) (ids []int64, distances []float32, err error)

func (*CPUIndex) SearchTurboQuant

func (i *CPUIndex) SearchTurboQuant(vector []float32, k int, bitsPerAngle int) ([]int64, []float32, error)

func (*CPUIndex) SearchUint8

func (i *CPUIndex) SearchUint8(vector []uint8, k int) ([]int64, []float32, error)

func (*CPUIndex) SearchUint16

func (i *CPUIndex) SearchUint16(vector []uint16, k int) ([]int64, []float32, error)

func (*CPUIndex) Sync

func (i *CPUIndex) Sync() error

func (*CPUIndex) TrainPQ

func (i *CPUIndex) TrainPQ(vectors []float32, m int, k int) error

func (*CPUIndex) UpdateGraph

func (i *CPUIndex) UpdateGraph(offsets []uint32, neighbors []uint32, weights []float32) error

type CircuitBreaker

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

CircuitBreaker implements the circuit breaker pattern for GPU operations

func NewCircuitBreaker

func NewCircuitBreaker(config CircuitBreakerConfig) *CircuitBreaker

NewCircuitBreaker creates a new circuit breaker

func (*CircuitBreaker) Allow

func (cb *CircuitBreaker) Allow() bool

Allow checks if a request should be allowed through

func (*CircuitBreaker) RecordFailure

func (cb *CircuitBreaker) RecordFailure()

RecordFailure records a failed operation

func (*CircuitBreaker) RecordSuccess

func (cb *CircuitBreaker) RecordSuccess()

RecordSuccess records a successful operation

func (*CircuitBreaker) State

func (cb *CircuitBreaker) State() CircuitState

State returns the current state of the circuit breaker

func (*CircuitBreaker) Stats

func (cb *CircuitBreaker) Stats() CircuitBreakerStats

Stats returns current circuit breaker statistics

type CircuitBreakerConfig

type CircuitBreakerConfig struct {
	// FailureThreshold is the number of consecutive failures before opening the circuit
	FailureThreshold int
	// SuccessThreshold is the number of consecutive successes in half-open state before closing
	SuccessThreshold int
	// Timeout is the duration the circuit stays open before transitioning to half-open
	Timeout time.Duration
}

CircuitBreakerConfig configures the circuit breaker

func DefaultCircuitBreakerConfig

func DefaultCircuitBreakerConfig() CircuitBreakerConfig

DefaultCircuitBreakerConfig returns a default configuration

type CircuitBreakerStats

type CircuitBreakerStats struct {
	State         string
	Failures      int
	Successes     int
	LastFailure   time.Time
	StateDuration time.Duration
}

CircuitBreakerStats holds circuit breaker statistics

func (CircuitBreakerStats) String

func (s CircuitBreakerStats) String() string

String returns a string representation of the stats

type CircuitState

type CircuitState int

CircuitState represents the state of the circuit breaker

const (
	// CircuitClosed means the circuit is closed and requests are allowed
	CircuitClosed CircuitState = iota
	// CircuitOpen means the circuit is open and requests are blocked
	CircuitOpen
	// CircuitHalfOpen means the circuit is testing if the service has recovered
	CircuitHalfOpen
)

func (CircuitState) String

func (s CircuitState) String() string

type DeviceStats

type DeviceStats struct {
	ID          int32
	Name        string
	TotalMemory int64
	UsedMemory  int64
	QueryCount  int64
	ErrorCount  int64
	LastUsed    time.Time
}

type GPUBackend

type GPUBackend = types.GPUBackend

Re-export basic types from types subpackage for convenience

func DetectGPUBackend

func DetectGPUBackend() GPUBackend

func GetPreferredBackend

func GetPreferredBackend() GPUBackend

GetPreferredBackend returns the best available GPU backend for the current system

type GPUComputeError

type GPUComputeError = types.GPUComputeError

type GPUConfig

type GPUConfig = types.GPUConfig

func DefaultGPUConfig

func DefaultGPUConfig() GPUConfig

DefaultGPUConfig returns default GPU configuration

type GPUDevice

type GPUDevice struct {
	ID         int32
	Index      types.Index
	MemPool    *memory.GPUMemPool
	Info       *types.GPUInfo
	QueryCount atomic.Int64
	ErrorCount atomic.Int64
	LastUsed   atomic.Int64
}

type GPUIndexPool

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

GPUIndexPool manages a pool of reusable GPU indexes This reduces allocation overhead and enables resource limiting

func NewGPUIndexPool

func NewGPUIndexPool(config GPUIndexPoolConfig) *GPUIndexPool

NewGPUIndexPool creates a new GPU index pool

func (*GPUIndexPool) Cleanup

func (p *GPUIndexPool) Cleanup() int

Cleanup removes expired idle indexes

func (*GPUIndexPool) Close

func (p *GPUIndexPool) Close() error

Close closes the pool and all indexes

func (*GPUIndexPool) GetGPUIndex

func (p *GPUIndexPool) GetGPUIndex(config types.GPUConfig) (types.Index, error)

GetGPUIndex gets a GPU index from the pool or creates a new one

func (*GPUIndexPool) ReturnGPUIndex

func (p *GPUIndexPool) ReturnGPUIndex(index types.Index) error

ReturnGPUIndex returns a GPU index to the pool

func (*GPUIndexPool) Stats

func (p *GPUIndexPool) Stats() GPUIndexPoolStats

Stats returns pool statistics

func (*GPUIndexPool) UpdateMetrics

func (p *GPUIndexPool) UpdateMetrics()

UpdateMetrics updates Prometheus metrics for the pool

type GPUIndexPoolConfig

type GPUIndexPoolConfig struct {
	MaxSize       int
	MaxConcurrent int
	IdleTimeout   time.Duration
}

GPUIndexPoolConfig configures the GPU index pool

func DefaultGPUIndexPoolConfig

func DefaultGPUIndexPoolConfig() GPUIndexPoolConfig

DefaultGPUIndexPoolConfig returns default pool configuration

type GPUIndexPoolStats

type GPUIndexPoolStats struct {
	Idle          int
	Active        int
	Waiting       int
	TotalCreated  int
	TotalReused   int
	MaxSize       int
	MaxConcurrent int
}

GPUIndexPoolStats contains pool statistics

type GPUIndexWrapper

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

GPUIndexWrapper provides high-scale dynamic routing between CPU index representations and high-throughput GPU index libraries (such as cuVS, Faiss GPU).

func NewGPUIndexWrapper

func NewGPUIndexWrapper(cfg types.GPUConfig, primary Index) (*GPUIndexWrapper, error)

NewGPUIndexWrapper wraps a primary index and instantiates a high-scale GPU index fallback.

func (*GPUIndexWrapper) Add

func (w *GPUIndexWrapper) Add(ids []int64, vectors []float32) error

Add delegates vector ingestion to both primary and high-scale indexes.

func (*GPUIndexWrapper) Backend

func (w *GPUIndexWrapper) Backend() types.GPUBackend

Backend returns the active GPU Backend

func (*GPUIndexWrapper) Close

func (w *GPUIndexWrapper) Close() error

Close closes all underlying indexes and releases VRAM pools.

func (*GPUIndexWrapper) GetRoutingStats

func (w *GPUIndexWrapper) GetRoutingStats() (cpuQPS int64, gpuQPS int64)

GetRoutingStats returns diagnostic routing QPS counters.

func (*GPUIndexWrapper) Search

func (w *GPUIndexWrapper) Search(vector []float32, k int) ([]int64, []float32, error)

Search dynamically routes queries to the optimal execution target based on query size and current QPS pressure.

func (*GPUIndexWrapper) SearchBatchDistances

func (w *GPUIndexWrapper) SearchBatchDistances(query []float32, candidateIDs []uint32) ([]float32, error)

SearchBatchDistances offloads batch distances to the GPU index if available.

type GPUInfo

type GPUInfo = types.GPUInfo

func DetectAvailableGPUs

func DetectAvailableGPUs() []GPUInfo

DetectAvailableGPUs returns information about all available GPU devices

func GetBestGPU

func GetBestGPU() (*GPUInfo, error)

GetBestGPU returns the best available GPU device info

func GetGPUByID

func GetGPUByID(deviceID int32) (*GPUInfo, error)

GetGPUByID returns GPU info for a specific device ID

type GPUInitializationError

type GPUInitializationError = types.GPUInitializationError

Error type re-exports

type GPUMemPool

type GPUMemPool = memory.GPUMemPool

Memory management re-exports

func NewGPUMemPool

func NewGPUMemPool(backend GPUBackend, deviceID int32) (*GPUMemPool, error)

type GPUMemoryError

type GPUMemoryError = types.GPUMemoryError

type GPUNotAvailableError

type GPUNotAvailableError = types.GPUNotAvailableError

type GPUSyncError

type GPUSyncError = types.GPUSyncError

type Index

type Index = types.Index

func NewIndex

func NewIndex(cfg GPUConfig) (Index, error)

NewIndex creates a GPU index with auto-detected backend (delegates to implementation)

func NewIndexWithBackend

func NewIndexWithBackend(cfg GPUConfig, backend GPUBackend) (Index, error)

NewIndexWithBackend creates a GPU index with specified backend (delegates to implementation)

func NewIndexWithConfig

func NewIndexWithConfig(_ GPUConfig) (Index, error)

NewIndexWithConfig is maintained for backward compatibility (stub)

func NewMetalIndexImpl

func NewMetalIndexImpl(_ GPUConfig) (Index, error)

NewMetalIndexImpl is maintained for backward compatibility (stub)

func NewMockIndex

func NewMockIndex(cfg GPUConfig, backend GPUBackend) Index

type KernelOpTime

type KernelOpTime struct {
	Name     string  `json:"name"`
	Calls    int64   `json:"calls"`
	TotalMS  float64 `json:"total_ms"`
	SharePct float64 `json:"share_pct"`
}

KernelOpTime is one named GPU operation's share of the device's time, and KernelProfile the whole table.

type KernelProfile

type KernelProfile struct {
	Ops           []KernelOpTime `json:"ops"`
	TotalMS       float64        `json:"total_ms"`
	UntimedCalls  int64          `json:"untimed_calls"`
	PoolExhausted int64          `json:"pool_exhausted"`
	// Supported is false when there is no CUDA backend in this build, so a
	// report can say "no kernels were measured" instead of "zero milliseconds".
	Supported bool `json:"supported"`
}

KernelOpTime is one named GPU operation's share of the device's time, and KernelProfile the whole table.

func CurrentKernelProfile

func CurrentKernelProfile() KernelProfile

CurrentKernelProfile returns an empty, unsupported profile.

func (KernelProfile) AttributedFraction

func (p KernelProfile) AttributedFraction() float64

AttributedFraction is the share of timed GPU time a named kernel accounts for. It is 1 when every op has a name.

func (KernelProfile) Table

func (p KernelProfile) Table() string

Table renders the profile as a fixed-width table.

type MockIndex

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

MockIndex implements the Index interface for testing purposes. It uses a simple in-memory map to store vectors and performs linear search.

func (*MockIndex) Add

func (m *MockIndex) Add(ids []int64, vectors []float32) error

func (*MockIndex) AddPQ

func (m *MockIndex) AddPQ(ids []int64, codes []byte, m_val int) error

func (*MockIndex) AddTurboQuant

func (m *MockIndex) AddTurboQuant(ids []int64, tqData []byte, bitsPerAngle int) error

func (*MockIndex) AssignToClusters

func (m *MockIndex) AssignToClusters(vectors []float32, centroids []float32) ([]uint32, error)

func (*MockIndex) Backend

func (m *MockIndex) Backend() GPUBackend

func (*MockIndex) Clear

func (m *MockIndex) Clear() error

func (*MockIndex) Close

func (m *MockIndex) Close() error

func (*MockIndex) DeviceID

func (m *MockIndex) DeviceID() int32

func (*MockIndex) EncodePQ

func (m *MockIndex) EncodePQ(vectors []float32) ([]byte, error)

func (*MockIndex) GetDeviceInfo

func (m *MockIndex) GetDeviceInfo() (*GPUInfo, error)

func (*MockIndex) GetMemoryInfo

func (m *MockIndex) GetMemoryInfo() (total, free, used int64, err error)

func (*MockIndex) GetUtilization

func (m *MockIndex) GetUtilization() (float32, error)

func (*MockIndex) GraphExpand

func (m *MockIndex) GraphExpand(seeds []uint32, depth int, alpha float32) ([]uint32, []float32, error)

func (*MockIndex) HaversineSearch

func (m *MockIndex) HaversineSearch(centerLat, centerLon float32, points []float32, earthRadius float32) ([]float32, error)

func (*MockIndex) NormBatch

func (m *MockIndex) NormBatch(vectors []float32, dims int) ([]float32, error)

func (*MockIndex) PruneNeighbors

func (m *MockIndex) PruneNeighbors(candidateIds []uint32, candidateDists []float32, maxNeighbors int, allVectors []float32) ([]uint32, error)

func (*MockIndex) Reset

func (m *MockIndex) Reset() error

func (*MockIndex) Search

func (m *MockIndex) Search(vector []float32, k int) ([]int64, []float32, error)

func (*MockIndex) SearchBatch

func (m *MockIndex) SearchBatch(vectors [][]float32, k int) ([][]int64, [][]float32, error)

func (*MockIndex) SearchBatchDistances

func (m *MockIndex) SearchBatchDistances(query []float32, candidateIDs []uint32) ([]float32, error)

func (*MockIndex) SearchComplex64

func (m *MockIndex) SearchComplex64(vector []uint16, k int) ([]int64, []float32, error)

func (*MockIndex) SearchComplex128

func (m *MockIndex) SearchComplex128(vector []float32, k int) ([]int64, []float32, error)

func (*MockIndex) SearchFloat16

func (m *MockIndex) SearchFloat16(vector []uint16, k int) ([]int64, []float32, error)

func (*MockIndex) SearchGreedy

func (m *MockIndex) SearchGreedy(query []float32, entryPoint uint32, entryDist float32) (uint32, float32, error)

func (*MockIndex) SearchInt8

func (m *MockIndex) SearchInt8(vector []int8, k int) ([]int64, []float32, error)

func (*MockIndex) SearchInt16

func (m *MockIndex) SearchInt16(vector []int16, k int) ([]int64, []float32, error)

func (*MockIndex) SearchPQ

func (m *MockIndex) SearchPQ(lookupTable []float32, m_val int, k int) ([]int64, []float32, error)

func (*MockIndex) SearchTurboQuant

func (m *MockIndex) SearchTurboQuant(vector []float32, k int, bitsPerAngle int) ([]int64, []float32, error)

func (*MockIndex) SearchUint8

func (m *MockIndex) SearchUint8(vector []uint8, k int) ([]int64, []float32, error)

func (*MockIndex) SearchUint16

func (m *MockIndex) SearchUint16(vector []uint16, k int) ([]int64, []float32, error)

func (*MockIndex) Sync

func (m *MockIndex) Sync() error

func (*MockIndex) TrainPQ

func (m *MockIndex) TrainPQ(vectors []float32, m_val int, k int) error

func (*MockIndex) UpdateGraph

func (m *MockIndex) UpdateGraph(offsets []uint32, neighbors []uint32, weights []float32) error

type MultiGPUConfig

type MultiGPUConfig struct {
	DeviceIDs        []int32
	Strategy         MultiGPUStrategy
	MaxMemoryPerGPU  int64
	EnableMigration  bool
	BalanceInterval  time.Duration
	MaxConcurrentGPU int // max concurrent GPU operations across all devices (0 = GOMAXPROCS)
}

func DefaultMultiGPUConfig

func DefaultMultiGPUConfig() MultiGPUConfig

type MultiGPUManager

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

func NewMultiGPUManager

func NewMultiGPUManager(config MultiGPUConfig, logger zerolog.Logger) (*MultiGPUManager, error)

func (*MultiGPUManager) AddVectors

func (m *MultiGPUManager) AddVectors(ids []int64, vectors []float32) error

func (*MultiGPUManager) AddVectorsSharded

func (m *MultiGPUManager) AddVectorsSharded(ids []int64, vectors []float32) error

func (*MultiGPUManager) Close

func (m *MultiGPUManager) Close() error

func (*MultiGPUManager) DeviceCount

func (m *MultiGPUManager) DeviceCount() int

func (*MultiGPUManager) EncodePQ

func (m *MultiGPUManager) EncodePQ(vectors []float32) ([]byte, error)

func (*MultiGPUManager) GetDevice

func (m *MultiGPUManager) GetDevice(deviceID int32) (*GPUDevice, error)

func (*MultiGPUManager) GetDeviceByVectorID

func (m *MultiGPUManager) GetDeviceByVectorID(id int64) (*GPUDevice, error)

func (*MultiGPUManager) GetStats

func (m *MultiGPUManager) GetStats() MultiGPUStats

func (*MultiGPUManager) ReplicateToAll

func (m *MultiGPUManager) ReplicateToAll(ids []int64, vectors []float32) error

func (*MultiGPUManager) Search

func (m *MultiGPUManager) Search(query []float32, k int) ([]int64, []float32, error)

func (*MultiGPUManager) SearchAllDevices

func (m *MultiGPUManager) SearchAllDevices(query []float32, k int) ([][]int64, [][]float32, []error)

func (*MultiGPUManager) SearchMerged

func (m *MultiGPUManager) SearchMerged(query []float32, k int) ([]int64, []float32, error)

func (*MultiGPUManager) SearchMergedPQ

func (m *MultiGPUManager) SearchMergedPQ(lookupTable []float32, mSub int, k int) ([]int64, []float32, error)

func (*MultiGPUManager) SearchPQ

func (m *MultiGPUManager) SearchPQ(lookupTable []float32, mSub int, k int) ([]int64, []float32, error)

func (*MultiGPUManager) SelectDevice

func (m *MultiGPUManager) SelectDevice() *GPUDevice

func (*MultiGPUManager) ShardDevice

func (m *MultiGPUManager) ShardDevice(vectorID int64) *GPUDevice

func (*MultiGPUManager) TrainPQ

func (m *MultiGPUManager) TrainPQ(vectors []float32, mSub, kCentroids int) error

type MultiGPUStats

type MultiGPUStats struct {
	DeviceCount  int
	Strategy     string
	TotalMemory  int64
	TotalQueries int64
	Devices      []DeviceStats
}

type MultiGPUStrategy

type MultiGPUStrategy int
const (
	StrategyRoundRobin MultiGPUStrategy = iota
	StrategyLoadBalance
	StrategyAffinity
	StrategyMemoryAware
)

func (MultiGPUStrategy) String

func (s MultiGPUStrategy) String() string

type TransferRequest

type TransferRequest struct {
	Src       *ZeroCopyBuffer
	Dst       *ZeroCopyBuffer
	Offset    int
	Size      int
	Completed chan error
}

type ZeroCopyBuffer

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

func NewPinnedBuffer

func NewPinnedBuffer(size int) (*ZeroCopyBuffer, error)

func NewZeroCopyBuffer

func NewZeroCopyBuffer(size int) (*ZeroCopyBuffer, error)

func (*ZeroCopyBuffer) AddRef

func (b *ZeroCopyBuffer) AddRef()

func (*ZeroCopyBuffer) Free

func (b *ZeroCopyBuffer) Free()

func (*ZeroCopyBuffer) Ptr

func (b *ZeroCopyBuffer) Ptr() unsafe.Pointer

func (*ZeroCopyBuffer) Release

func (b *ZeroCopyBuffer) Release() int

func (*ZeroCopyBuffer) Size

func (b *ZeroCopyBuffer) Size() int

func (*ZeroCopyBuffer) Slice

func (b *ZeroCopyBuffer) Slice() []byte

type ZeroCopyManager

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

func NewZeroCopyManager

func NewZeroCopyManager(workers int, bufferSizes []int) *ZeroCopyManager

func (*ZeroCopyManager) Close

func (zcm *ZeroCopyManager) Close()

func (*ZeroCopyManager) TransferAsync

func (zcm *ZeroCopyManager) TransferAsync(req TransferRequest)

func (*ZeroCopyManager) TransferSync

func (zcm *ZeroCopyManager) TransferSync(req TransferRequest) error

type ZeroCopyPool

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

func NewZeroCopyPool

func NewZeroCopyPool(sizes []int, maxPerSize int) *ZeroCopyPool

func (*ZeroCopyPool) Acquire

func (p *ZeroCopyPool) Acquire(size int) (*ZeroCopyBuffer, error)

func (*ZeroCopyPool) Release

func (p *ZeroCopyPool) Release(buf *ZeroCopyBuffer)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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