lib/memtrace/src/root.zig
daab053ee43316e1809a84551d573ddd1e5bf3d2
1 //! Memtrace records where a program's memory goes: which phase allocated it,
2 //! from which call site, and how much of it is still live.
3 //!
4 //! A recorder, the *tracer*, records each operation against the scope in force
5 //! and answers with summaries and events. It wraps the allocator the caller
6 //! hands it, the *backing allocator*, and forwards every operation to it.
7 //! Wrapping one allocator at a time scopes the record to the subsystem the
8 //! caller chose.
9 //!
10 //! An `enter` call opens a named region of execution, the *scope*, which names
11 //! the phase that later allocations are attributed to and closes when its span
12 //! exits. A bounded table of labeled byte counts a caller reports by hand, the
13 //! *census*, records memory beyond what the allocator names on its own.
14 //!
15 //! A subsystem passes down a handle holding an optional tracer, an optional
16 //! census, and an optional interval sink, the *participation context*. A
17 //! disabled context leaves every call through it inert, so a subsystem keeps
18 //! one code path whether an observer is present or absent.
19 //!
20 //! When recording an allocation fails, `rawAlloc` frees the memory it obtained
21 //! and answers null, which keeps live memory out of the program that the record
22 //! does not mention. For a resize, a remap, or a free, a recording failure
23 //! raises the tracer's failure flag and the memory operation stands, which
24 //! leaves the capture partial. A tracer writes a summary of live and high-water
25 //! bytes per scope, and a JSONL event stream, and its analysis reports capture
26 //! integrity beside those totals so a partial capture is visible in the output.
27
28 const event_mod = @import("event.zig");
29 const coverage_mod = @import("coverage.zig");
30 const tracer_mod = @import("tracer.zig");
31 const census_mod = @import("census/root.zig");
32 const context_mod = @import("context.zig");
33 const analysis_mod = @import("analysis.zig");
34 const causal_mod = @import("causal.zig");
35 const cli_mod = @import("cli.zig");
36 const ledger_mod = @import("ledger.zig");
37 const stack_mod = @import("stack/root.zig");
38
39 pub const event = event_mod;
40 pub const coverage = coverage_mod;
41 pub const census = census_mod;
42 pub const context = context_mod;
43 pub const analysis = analysis_mod;
44 pub const causal = causal_mod;
45 pub const cli = cli_mod;
46 pub const ledger = ledger_mod;
47 pub const stack = stack_mod;
48
49 pub const Analyzer = analysis_mod.Analyzer;
50 pub const AnalysisSummaryOptions = analysis_mod.SummaryOptions;
51 pub const AllocationLedger = ledger_mod.AllocationLedger;
52 pub const AllocationRecord = ledger_mod.Record;
53 pub const CaptureIntegrity = analysis_mod.CaptureIntegrity;
54 pub const Config = tracer_mod.Config;
55 pub const Context = context_mod.Context;
56 pub const IntervalSink = context_mod.IntervalSink;
57 pub const IntervalSpan = context_mod.IntervalSpan;
58 pub const Difference = tracer_mod.Difference;
59 pub const OwnedObservation = tracer_mod.OwnedObservation;
60 pub const Scope = tracer_mod.Scope;
61 pub const Span = context_mod.Span;
62 pub const Snapshot = tracer_mod.Snapshot;
63 pub const Retention = tracer_mod.Retention;
64 pub const SummaryOptions = tracer_mod.SummaryOptions;
65 pub const Tracer = tracer_mod.Tracer;
66 pub const TracingAllocator = tracer_mod.TracingAllocator;
67 pub const request_site_capacity_max = tracer_mod.request_site_capacity_max;
68 pub const AllocationAttribution = stack_mod.Attribution;
69
70 pub const Census = census_mod.Census;
71 pub const CensusCapacity = census_mod.Capacity;
72 pub const CensusCapacityError = census_mod.DeriveError;
73 pub const CensusEntry = census_mod.Entry;
74 pub const CensusExhaustion = census_mod.Exhaustion;
75 pub const CensusLimits = census_mod.Limits;
76 pub const CensusStatus = census_mod.Status;
77 pub const CensusStorage = census_mod.Storage;
78 pub const CensusStorageExhaustion = census_mod.StorageExhaustion;
79 pub const CensusStorageStatus = census_mod.StorageStatus;
80 pub const CensusSummaryOptions = census_mod.SummaryOptions;
81 pub const Event = event_mod.Event;
82 pub const EventKind = event_mod.Kind;
83 pub const EventLayer = event_mod.Layer;