freelist

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestHookFreeBeforeChecksum func()

TestHookFreeBeforeChecksum is a test-only hook that fires after a freelist entry is written but before the page checksum is updated. It should remain nil in production.

Functions

This section is empty.

Types

type Allocator

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

func New

func New(p *pager.Pager, head uint64) *Allocator

func (*Allocator) Alloc

func (a *Allocator) Alloc(hint uint64) (uint64, error)

Alloc allocates a single page. hint is a page ID that the caller would like the new page to be close to. If hint is 0, the allocator uses its own heuristics (e.g. lastAlloc).

func (*Allocator) AllocMany

func (a *Allocator) AllocMany(count int, hint uint64) ([]uint64, error)

AllocMany allocates up to count pages in one pass. It returns any allocated IDs even if an error occurs so callers can retire them.

func (*Allocator) Free

func (a *Allocator) Free(id uint64) error

Free adds a page to the freelist.

func (*Allocator) Head

func (a *Allocator) Head() uint64

func (*Allocator) SetFreelistRegion

func (a *Allocator) SetFreelistRegion(pages uint64, radius int)

func (*Allocator) SetHead

func (a *Allocator) SetHead(h uint64)

func (*Allocator) SetPreferAppend

func (a *Allocator) SetPreferAppend(prefer bool)

func (*Allocator) Stats added in v0.2.0

func (a *Allocator) Stats(pageLimit uint64) (Stats, error)

Stats returns freelist page counts while holding the allocator lock to avoid concurrent freelist mutations.

type Stats added in v0.2.0

type Stats struct {
	Head    uint64
	Pages   uint64
	FreeIDs uint64
}

Stats reports freelist metadata under the allocator lock.

func (Stats) ReclaimablePages added in v0.2.0

func (s Stats) ReclaimablePages() uint64

ReclaimablePages returns the total number of reclaimable pages tracked in the freelist.

Jump to

Keyboard shortcuts

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