Documentation
¶
Overview ¶
Package memsize estimates the resident footprint of in-memory index structures, so identity state — the symbol table, the series index and the postings lists, none of which the buffered sample/record byte counters see — can be metered and reported to an operator.
The estimates are structural: they count the bytes a structure owns (backing arrays, map slots, interned payloads), not the exact allocator footprint, so they ignore size-class rounding and allocation headers. They are accurate enough to size a cap against and to make growth visible; they are not a heap profiler.
Every helper counts the *fixed* part of a type only — the bytes a value that a pointer, slice header or interface field refers to are counted where they are owned, so a shared payload (an interned label) is charged once rather than to each of its references. It is the single place in the module that needs unsafe.Sizeof; callers state their intent with types instead.
Index ¶
Constants ¶
const MapBase = 48
MapBase is the runtime map header a map variable points at (a Go map value is one pointer word; the header holding the seed, the directory and the counters is a separate allocation). It is paid once per map regardless of contents, which only matters where maps are per-key rather than per-structure — the postings index keeps one value map per label name.
Variables ¶
This section is empty.
Functions ¶
func Map ¶
func Map[K comparable, V any](m map[K]V) int64
Map returns the estimated bytes of a whole map: its header plus its current entries.
func MapEntry ¶
func MapEntry[K comparable, V any]() int64
MapEntry returns the estimated bytes one entry of a map[K]V occupies: its key, its value, and its share of the slot bookkeeping and the map's occupancy slack. The map header itself is MapBase, counted separately because it is per-map rather than per-entry.
Types ¶
This section is empty.