Documentation
¶
Index ¶
- Variables
- type Allocator
- func (a *Allocator) Alloc(hint uint64) (uint64, error)
- func (a *Allocator) AllocMany(count int, hint uint64) ([]uint64, error)
- func (a *Allocator) Counters() Stats
- func (a *Allocator) Free(id uint64) error
- func (a *Allocator) Head() uint64
- func (a *Allocator) SetFreelistRegion(pages uint64, radius int)
- func (a *Allocator) SetHead(h uint64)
- func (a *Allocator) SetPreferAppend(prefer bool)
- func (a *Allocator) Stats(pageLimit uint64) (Stats, error)
- type Stats
Constants ¶
This section is empty.
Variables ¶
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 (*Allocator) Alloc ¶
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 ¶
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) Counters ¶ added in v0.6.0
Counters reports cheap in-memory allocator counters without walking freelist pages. Use Stats when callers explicitly need on-disk reclaimable page counts.
func (*Allocator) SetFreelistRegion ¶
func (*Allocator) SetPreferAppend ¶
type Stats ¶ added in v0.2.0
type Stats struct {
Head uint64
Pages uint64
FreeIDs uint64
AllocPages uint64
AppendAllocPages uint64
ReuseAllocPages uint64
FreePages uint64
}
Stats reports freelist metadata under the allocator lock.
func (Stats) ReclaimablePages ¶ added in v0.2.0
ReclaimablePages returns the total number of reclaimable pages tracked in the freelist.