iouring

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package iouring implements an engine backed by Linux io_uring.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferGroup

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

BufferGroup manages a group of provided buffers for multishot recv.

func NewBufferGroup

func NewBufferGroup(ring *Ring, groupID uint16, count, size int) (*BufferGroup, error)

NewBufferGroup creates and registers a provided buffer group with the ring.

func (*BufferGroup) AvailableCount

func (bg *BufferGroup) AvailableCount() int

AvailableCount returns the number of available buffers.

func (*BufferGroup) GetBuffer

func (bg *BufferGroup) GetBuffer(bufID uint16) []byte

GetBuffer returns the buffer for the given buffer ID.

func (*BufferGroup) ReturnBuffer

func (bg *BufferGroup) ReturnBuffer(ring *Ring, bufID uint16) error

ReturnBuffer returns a buffer to the group and re-provides it to the kernel.

type Engine

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

Engine implements the io_uring-based I/O engine.

func New

func New(cfg resource.Config, handler stream.Handler) (*Engine, error)

New creates a new io_uring engine.

func (*Engine) Addr

func (e *Engine) Addr() net.Addr

Addr returns the bound listener address.

func (*Engine) Listen

func (e *Engine) Listen(ctx context.Context) error

Listen starts the io_uring engine and blocks until context is canceled.

func (*Engine) Metrics

func (e *Engine) Metrics() engine.EngineMetrics

Metrics returns a snapshot of engine metrics.

func (*Engine) Shutdown

func (e *Engine) Shutdown(_ context.Context) error

Shutdown gracefully shuts down the engine.

func (*Engine) Type

func (e *Engine) Type() engine.EngineType

Type returns the engine type.

type Ring

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

Ring is an io_uring instance with mmap'd SQ/CQ rings and SQE array.

func NewRing

func NewRing(entries uint32, flags uint32) (*Ring, error)

NewRing creates a new io_uring instance.

func (*Ring) AdvanceCQ

func (r *Ring) AdvanceCQ()

AdvanceCQ advances the CQ head by one.

func (*Ring) Close

func (r *Ring) Close() error

Close closes the ring and unmaps memory.

func (*Ring) GetSQE

func (r *Ring) GetSQE() unsafe.Pointer

GetSQE returns a pointer to the next available SQE, or nil if the ring is full.

func (*Ring) Submit

func (r *Ring) Submit() (int, error)

Submit submits pending SQEs to the kernel.

func (*Ring) SubmitAndWait

func (r *Ring) SubmitAndWait() error

SubmitAndWait submits pending SQEs and waits for at least one CQE.

func (*Ring) SubmitAndWaitTimeout

func (r *Ring) SubmitAndWaitTimeout(timeout time.Duration) error

SubmitAndWaitTimeout submits pending SQEs and waits for at least one CQE, with a timeout. Returns nil on timeout (ETIME) or EINTR.

func (*Ring) WaitCQE

func (r *Ring) WaitCQE() error

WaitCQE waits for at least one CQE to become available.

func (*Ring) WakeupSQPoll

func (r *Ring) WakeupSQPoll() error

WakeupSQPoll wakes up the SQPOLL thread if it went to sleep.

type TierStrategy

type TierStrategy interface {
	Tier() engine.Tier
	SetupFlags() uint32
	PrepareAccept(ring *Ring, listenFD int)
	PrepareRecv(ring *Ring, fd int, buf []byte)
	PrepareSend(ring *Ring, fd int, buf []byte, linked bool)
	SupportsProvidedBuffers() bool
	SupportsMultishotAccept() bool
	SupportsMultishotRecv() bool
	SQPollIdle() uint32
}

TierStrategy configures io_uring behavior based on detected capabilities.

func SelectTier

func SelectTier(profile engine.CapabilityProfile) TierStrategy

SelectTier returns the highest available tier strategy for the given profile.

type Worker

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

Worker is a per-core io_uring event loop.

Jump to

Keyboard shortcuts

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