tiny.profiling.ingest
Defined in tiny.profiling.
API (24)
Actions
Public operations.
Types and contracts
Public types and contracts.
Namespaces
Public namespaces.
capacityclassifycollectiondifferentialduplicateeventinspectionmatchingmodeloutputownerparserselector
Values and defaults
Public values and defaults.
Source
Source: src/profiling/ingest/differential.zig
zig
const std = @import("std");const profiling = @import("../root.zig");const ingest = @import("root.zig");const Legacy = struct { valid: bool, totals: profiling.allocation.Totals = .{},};fn legacy(bytes: []const u8) Legacy { std.debug.assert(bytes.len >= 2); std.debug.assert(bytes[0] == '{'); std.debug.assert(bytes[bytes.len - 1] == '}'); var parsed = std.json.parseFromSlice( std.json.Value, std.testing.allocator, bytes, .{}, ) catch return .{ .valid = false }; defer parsed.deinit(); const object = profiling.json.object(parsed.value) catch return .{ .valid = false }; var totals = profiling.allocation.Totals{}; if (profiling.schema.classify(object, "allocations").family == .allocation) { totals.record(object); } return .{ .valid = true, .totals = totals };}fn strict(bytes: []const u8) !Legacy { std.debug.assert(bytes.len <= 2048); var json_stack: [64]u8 = undefined; var key_bytes: [2048]u8 = undefined; var keys: [128]ingest.classify.KeyEntry = undefined; var objects: [64]ingest.classify.ObjectFrame = undefined; std.debug.assert(json_stack.len * 8 >= objects.len); std.debug.assert(keys.len >= objects.len); const parsed = try ingest.classify.line(bytes, .{ .json_stack = &json_stack, .key_bytes = &key_bytes, .keys = &keys, .objects = &objects, }); var totals = profiling.allocation.Totals{}; if (parsed.valid) ingest.classify.record(&totals, parsed.event); return .{ .valid = parsed.valid, .totals = totals };}const cases = [_][]const u8{ "{\"kind\":\"alloc\",\"len\":64}", "{\"k\\u0069nd\":\"alloc\",\"l\\u0065n\":18446744073709551615}", "{\"kind\":\"resize\",\"len\":4,\"old_len\":8,\"new_len\":1.2e1}", "{\"kind\":\"remap\",\"old_len\":2e0,\"new_len\":5E0,\"nested\":{\"x\":[1,{},true]}}", "{\"kind\":\"allocator\",\"metadata\":{\"name\":\"gpa\"}}", "{\"kind\":\"unknown\",\"len\":3}", "{\"schema\":\"tiny.profiling.metric/v1\",\"kind\":\"alloc\",\"len\":9}", "{\"sch\\u0065ma\":\"tiny.profiling.metric\\/v1\",\"kind\":\"free\"}", "{\"schema\":\"other\",\"kind\":\"alloc\",\"len\":9}", "{\"event\":\"bench_end\",\"sample_ns\":[],\"kind\":\"alloc\",\"len\":9}", "{\"event\":\"bench_end\",\"sample_ns\":{},\"kind\":\"alloc\",\"len\":9}", "{\"event\":\"bench_end\",\"alloc_bytes\":0,\"kind\":\"alloc\",\"len\":9}", "{\"event\":\"bench_end\",\"alloc_count\":1e999,\"kind\":\"free\"}", "{\"event\":\"bench_end\",\"alloc_bytes\":\"0\",\"kind\":\"alloc\",\"len\":9}", "{\"event\":false,\"sample_ns\":[],\"kind\":\"alloc\",\"len\":9}", "{\"kind\":\"summary\",\"mean_ns\":1}", "{\"kind\":\"summary\",\"summary\":\"memory\",\"retained_bytes\":2}", "{\"kind\":\"summary\",\"summary\":\"other\",\"retained_bytes\":2}", "{\"kind\":\"alloc\",\"kind\":\"free\",\"len\":1}", "{\"kind\":\"alloc\",\"nested\":{\"same\":1,\"same\":2}}", "{\"kind\":\"alloc\",}", "{\"kind\":false,\"len\":2.0}", "{\"kind\":\"resize\",\"old_len\":16,\"new_len\":4}", "{\"kind\":\"resize\",\"len\":4,\"new_len\":12}", "{\"kind\":\"remap\",\"old_len\":\"2\",\"new_len\":5}", "{\"k\\u0069nd\":\"alloc\",\"kind\":\"free\",\"len\":1}", "{\"kind\":\"alloc\",\"l\\u0065n\":3,\"nested\":{\"x\":1}}", "{\"allocated_count\":4,\"kind\":\"alloc\",\"len\":1}", "{\"high_water_live_byte\":1,\"kind\":\"summary\",\"summary\":\"memory\"}", "{\"sample_ns_extra\":[],\"event\":\"bench_end\",\"kind\":\"alloc\",\"len\":2}",};test "ingestion classifier matches legacy dynamic JSON semantics" { comptime { @stardustClaim( @import("alloc_phase").capacity.witness(@import("./root.zig").ArtifactIngestion, "profiling_ingestion_differential"), null, null, null, null, null, null, ); } std.debug.assert(cases.len == 30); for (cases) |bytes| { const expected = legacy(bytes); const actual = try strict(bytes); try std.testing.expectEqual(expected.valid, actual.valid); try std.testing.expectEqual(expected.totals, actual.totals); }}Source: src/profiling/ingest/root.zig
zig
pub const model = @import("model.zig");pub const inspection = @import("inspection.zig");pub const event = @import("event.zig");pub const matching = @import("matching.zig");pub const duplicate = @import("duplicate.zig");pub const selector = @import("selector.zig");pub const parser = @import("parser.zig");pub const capacity = @import("capacity.zig");pub const classify = @import("classify.zig");pub const differential = @import("differential.zig");pub const output = @import("output.zig");pub const owner = @import("owner.zig");pub const collection = @import("collection.zig");pub const schema = model.schema;pub const Paths = model.Paths;pub const Summary = model.Summary;pub const Source = model.Source;pub const SourceKind = model.SourceKind;pub const SourceFacts = model.SourceFacts;pub const Facts = model.Facts;pub const Limits = model.Limits;pub const Capacity = capacity.Capacity;pub const ArtifactIngestion = owner.ArtifactIngestion;pub const collect = collection.collect;Source: src/profiling/root.zig:27
zig
pub const ingest = @import("ingest/root.zig");Audit
| Definitions | 2 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |