Skip to documentation
SLOP

tiny.memtrace.CensusStorage

Reference tiny.memtrace CensusStorage

Defined in tiny.memtrace.

API (19)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

No direct callersNo direct callstiny.memtraceCensusStorage
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/memtrace/src/census/storage.zig:25

zig
pub const Storage = struct {    phase: alloc_phase.capacity.Phase,    capacity: capacity_mod.Capacity,    bytes: []align(capacity_mod.storage_alignment) u8,    slots: []model.Slot,    summary: []model.Entry,    labels: []u8,    joined_label: []u8,    in_use: bool = false,    pub const Limits: type = capacity_mod.Limits;    pub const Capacity: type = capacity_mod.Capacity;    pub const Exhaustion: type = @import("storage.zig").Exhaustion;    pub const InitError = std.mem.Allocator.Error || capacity_mod.DeriveError;    pub const claim: alloc_phase.capacity.Declaration = .{        .source = .{            .id = "memtrace.census_storage",            .kind = .phase_static,            .limit_source = .caller,            .storage = .{                .covered = &.{                    .{                        .id = "bounded_census_category_hash_table",                        .lifetime = .steady,                        .detail = "bounded census category hash table",                    },                    .{                        .id = "retained_category_label_bytes",                        .lifetime = .steady,                        .detail = "retained category label bytes",                    },                    .{                        .id = "prefixed_label_join_scratch",                        .lifetime = .steady,                        .detail = "prefixed-label join scratch",                    },                    .{                        .id = "sorted_summary_entry_scratch",                        .lifetime = .steady,                        .detail = "sorted summary entry scratch",                    },                },                .excluded = &.{                    "the caller-owned output writer and its storage",                    "allocation events and tracer state outside the semantic census",                },            },            .capacity = .{                .inputs = &.{                    alloc_phase.capacity.bindInput(Limits, "categories", "categories"),                    alloc_phase.capacity.bindInput(Limits, "label_bytes", "label_bytes"),                    alloc_phase.capacity.bindInput(Limits, "joined_label_bytes", "joined_label_bytes"),                },                .type_selectors = &.{                    alloc_phase.capacity.bindType(model.Slot, "slot"),                    alloc_phase.capacity.bindType(model.Entry, "entry"),                },                .nodes = &.{                    .{ .input = 0 },                    .{ .scale = .{ .node = 0, .coefficient = .{ .literal = 2 } } },                    .{ .next_power_of_two = 1 },                    .{ .scale = .{ .node = 2, .coefficient = .{ .size_of_concrete_type = 0 } } },                    .{ .alignment = .{ .node = 3, .alignment = .{ .literal = 16 } } },                    .{ .scale = .{ .node = 0, .coefficient = .{ .size_of_concrete_type = 1 } } },                    .{ .alignment = .{ .node = 5, .alignment = .{ .literal = 16 } } },                    .{ .input = 1 },                    .{ .input = 2 },                    .{ .add = .{ .left = 4, .right = 6 } },                    .{ .add = .{ .left = 9, .right = 7 } },                    .{ .add = .{ .left = 10, .right = 8 } },                },                .assertions = &.{.{                    .scope = .closure_total,                    .measure = .retained,                    .relation = .exact,                    .expression = 11,                }},            },            .overload = .{                .kind = .reject_before_mutation,                .detail = "named category, retained-label, joined-label, and counter exhaustion leaves aggregate entries unchanged",            },            .risks = .{                .transitive = .{                    .status = .witnessed,                    .detail = "recording, prefix joins, summary sorting, and JSONL emission use only the acquired census regions after activation",                },                .foreign = .{                    .status = .excluded,                    .detail = "writer effects and writer-owned buffering remain outside Census storage",                },            },            .obligations = &.{                .{ .key = "memtrace_census_capacity", .role = .capacity_model },                .{ .key = "memtrace_census_acquisition", .role = .custom },                .{ .key = "memtrace_census_oom", .role = .custom },                .{ .key = "memtrace_census_boundary", .role = .overload },                .{ .key = "memtrace_census_overflow", .role = .overload },                .{ .key = "memtrace_census_reuse", .role = .overload },                .{ .key = "memtrace_census_sealed", .role = .transitive_risk },                .{ .key = "memtrace_census_output", .role = .foreign_risk },                .{ .key = "memtrace_census_root", .role = .custom },            },        },        .bindings = .{            .owner = @This(),            .seal = .{                .family = alloc_phase.capacity.selector(@This().activate),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },            .teardown = .{                .family = alloc_phase.capacity.selector(@This().deinit),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },        },    };    pub fn init(allocator: std.mem.Allocator, limits: Limits) InitError!Storage {        const capacity = try Capacity.derive(limits);        const bytes = try allocator.alignedAlloc(            u8,            .fromByteUnits(capacity_mod.storage_alignment),            capacity.storage_bytes,        );        return .{            .phase = .initialization,            .capacity = capacity,            .bytes = bytes,            .slots = typedSlice(model.Slot, bytes, capacity.table_offset, capacity.table_slots),            .summary = typedSlice(model.Entry, bytes, capacity.summary_offset, capacity.summary_entries),            .labels = bytes[capacity.label_offset..][0..capacity.label_bytes],            .joined_label = bytes[capacity.joined_label_offset..][0..capacity.joined_label_bytes],        };    }    pub fn activate(self: *Storage) void {        std.debug.assert(self.phase == .initialization);        std.debug.assert(self.bytes.len == self.capacity.storage_bytes);        self.phase = .steady;    }    pub fn acquire(self: *Storage) Storage.Exhaustion!Regions {        std.debug.assert(self.phase == .steady);        if (self.in_use) return error.CensusStorageInUse;        @memset(self.slots, .{});        self.in_use = true;        return .{            .slots = self.slots,            .summary = self.summary,            .labels = self.labels,            .joined_label = self.joined_label,        };    }    pub fn release(self: *Storage) void {        std.debug.assert(self.phase == .steady);        std.debug.assert(self.in_use);        self.in_use = false;    }    pub fn status(self: *const Storage) Status {        return .{            .phase = self.phase,            .in_use = self.in_use,            .storage_bytes = self.capacity.storage_bytes,            .category_capacity = self.capacity.categories,            .table_slots = self.capacity.table_slots,            .label_bytes_capacity = self.capacity.label_bytes,            .joined_label_bytes_capacity = self.capacity.joined_label_bytes,        };    }    pub fn deinit(self: *Storage, allocator: std.mem.Allocator) void {        std.debug.assert(self.phase != .teardown);        std.debug.assert(!self.in_use);        std.debug.assert(self.bytes.len == self.capacity.storage_bytes);        self.phase = .teardown;        allocator.free(self.bytes);        self.bytes = &.{};        self.slots = &.{};        self.summary = &.{};        self.labels = &.{};        self.joined_label = &.{};    }};

Source: lib/memtrace/src/root.zig:77

zig
pub const CensusStorage = census_mod.Storage;
Called byCallsNo direct callstest sourcelib.memtrace.src.census.storagetest: Census storage acquires one exa...CensusStorageacquire
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.memtrace.src.census.storagetest: Census storage acquires one exa...CensusStorageactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.memtrace.src.census.storagecheckInitFailurestest sourcelib.memtrace.src.census.storagetest: Census storage acquires one exa...CensusStoragedeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsprivate sourcelib.memtrace.src.census.storagecheckInitFailurestest sourcelib.memtrace.src.census.storagetest: Census storage acquires one exa...private sourcelib.memtrace.src.census.storagetypedSliceCensusStorageinit
Static calls · unresolved targets: 1 · external targets: 1.
Called byCallsNo direct callstest sourcelib.memtrace.src.census.storagetest: Census storage acquires one exa...CensusStoragerelease
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.memtrace.src.census.storagetest: Census storage acquires one exa...CensusStoragestatus
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

census.Storage.

Audit

Definitions11
Public names22
Members8
Version26.7.0
Revisiondaab053ee433