Skip to main content

Module chunked_vec

Module chunked_vec 

Source
Expand description

A push-only vector that grows in fixed-size chunks instead of one contiguous reallocating buffer.

The trade-off vs. Vec:

  • One pointer indirection per indexed access (chunk lookup โ†’ element).
  • Slightly larger per-element overhead from chunk pointers (negligible at 64K elements/chunk).
  • References returned by index/index_mut are stable across push (a future-useful property; not currently relied on).

API is intentionally minimal โ€” only the operations the trace server needs (push, len, indexed access, get, truncate).

Structsยง

ChunkedVec

Constantsยง

CHUNK_SIZE ๐Ÿ”’
Number of elements per chunk. Power of two so idx / CHUNK_SIZE and idx % CHUNK_SIZE compile to a shift and a mask.

Functionsยง

new_chunk ๐Ÿ”’
Allocate a fresh chunk on the heap without ever materializing a CHUNK_SIZE-element array on the stack.
split_index ๐Ÿ”’
Returns the chunk index and intra-chunk offset for an element index.

Type Aliasesยง

Chunk ๐Ÿ”’