Help us shape the future of Go! Take the 2026 Go Developer Survey

mincore

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultUpdateInterval = 10 * time.Second
)

Limiter defaults.

Variables

This section is empty.

Functions

func Mincore

func Mincore(data []byte) ([]byte, error)

Mincore is a wrapper function for mincore(2).

Types

type Limiter

type Limiter struct {

	// Frequency of updates of the in-core vector.
	// Updates are performed lazily so this is the maximum frequency.
	UpdateInterval time.Duration

	// OS mincore() function.
	Mincore func(data []byte) ([]byte, error)
	// contains filtered or unexported fields
}

Limiter represents a token bucket rate limiter based on

func NewLimiter

func NewLimiter(underlying *rate.Limiter, data []byte) *Limiter

NewLimiter returns a new instance of Limiter associated with an mmap. The underlying limiter can be shared to limit faults across the entire process.

func (*Limiter) IsInCore

func (l *Limiter) IsInCore(ptr uintptr) bool

IsInCore returns true if the address is resident in memory or if the address is outside the range of the data the limiter is tracking.

func (*Limiter) Update

func (l *Limiter) Update() error

Update updates the vector of in-core pages. Automatically updated when calling Wait().

func (*Limiter) WaitPointer

func (l *Limiter) WaitPointer(ctx context.Context, ptr unsafe.Pointer) error

WaitPointer checks if ptr would cause a page fault and, if so, rate limits its access. Once a page access is limited, it's updated to be considered memory resident.

func (*Limiter) WaitRange

func (l *Limiter) WaitRange(ctx context.Context, b []byte) error

WaitRange checks all pages in b for page faults and, if so, rate limits their access. Once a page access is limited, it's updated to be considered memory resident.

Jump to

Keyboard shortcuts

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