For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo struct
HiSparseStateLayout
struct HiSparseStateLayout[page_size: Int, hot_pages: Int, num_groups: Int, max_misses: Int, hash_capacity: Int]
Byte layout of a request's HiSparse state page.
Parameters
- page_size (
Int): Rows per cache page. - hot_pages (
Int): Pages in the hot buffer; it holdshot_pages * page_sizeslots. - num_groups (
Int): Indexer layers that keep their own LRU state. - max_misses (
Int): Most distinct host-only selections one request may make in one call, summed over its rows. - hash_capacity (
Int): Entries in the per-call hash of those selections; a power of two abovemax_misses.
Implemented traits
comptime members
BYTES
comptime BYTES = (_align16(Int((add (mul hot_pages, page_size, 4), _align16(Int((add (mul max_misses, 4), _align16(Int((add (mul max_misses, 4), _align16(Int((add (mul max_misses, 8), 64)))))))))))) + Int((mul _align16(Int((add (mul hot_pages, page_size, 8), 16))), num_groups)))
Bytes the state needs; must fit one cache page.
EPOCH
comptime EPOCH = 0
UInt32 call counter, bumped by every resolve.
GROUP_INIT
comptime GROUP_INIT = 0
UInt32, nonzero once the group's order is initialized.
GROUP_KEYS
comptime GROUP_KEYS = 16
Int32[hot_rows], the position each slot holds plus one, or 0.
GROUP_ORDER0
comptime GROUP_ORDER0 = (Int(16) + (Int(4) * HiSparseStateLayout[page_size, hot_pages, num_groups, max_misses, hash_capacity].hot_rows))
Int16[hot_rows] slots, least recently used first.
GROUP_ORDER1
comptime GROUP_ORDER1 = (HiSparseStateLayout[page_size, hot_pages, num_groups, max_misses, hash_capacity].GROUP_ORDER0 + (Int(2) * HiSparseStateLayout[page_size, hot_pages, num_groups, max_misses, hash_capacity].hot_rows))
The other order buffer.
GROUP_STRIDE
comptime GROUP_STRIDE = _align16((HiSparseStateLayout[page_size, hot_pages, num_groups, max_misses, hash_capacity].GROUP_ORDER1 + (Int(2) * HiSparseStateLayout[page_size, hot_pages, num_groups, max_misses, hash_capacity].hot_rows)))
Bytes per group.
GROUP_WHICH
comptime GROUP_WHICH = 4
UInt32, which order buffer is current.
GROUPS
comptime GROUPS = _align16(Int((add (mul hot_pages, page_size, 4), _align16(Int((add (mul max_misses, 4), _align16(Int((add (mul max_misses, 4), _align16(Int((add (mul max_misses, 8), 64))))))))))))
Start of the per-group LRU state.
HITS
comptime HITS = _align16(Int((add (mul max_misses, 4), _align16(Int((add (mul max_misses, 4), _align16(Int((add (mul max_misses, 8), 64)))))))))
UInt32[hot_rows], the epoch of the call that last hit each slot.
hot_rows
comptime hot_rows = (hot_pages * page_size)
Slots in the hot buffer.
MISS_COUNT
comptime MISS_COUNT = 4
Int32 misses queued by the last resolve.
MISS_HASH
comptime MISS_HASH = _align16((Int(64) + (Int(8) * max_misses)))
Int32[max_misses] hash entry of each miss, scratch.
MISS_LIST
comptime MISS_LIST = 64
Int32[max_misses, 2] of (hot row, host row) pairs.
VICTIMS
comptime VICTIMS = _align16(Int((add (mul max_misses, 4), _align16(Int((add (mul max_misses, 8), 64))))))
Int32[max_misses] slot taken by each miss, scratch.