commonware_allocator/mimalloc/
metrics.rs1use super::Stats;
8
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11pub enum Kind {
12 Gauge,
14 Counter,
16}
17
18#[derive(Clone, Copy, Debug)]
20pub struct Metric {
21 pub name: &'static str,
23 pub help: &'static str,
25 pub kind: Kind,
27 pub read: fn(&Stats) -> u64,
29}
30
31pub const METRICS: [Metric; 13] = [
33 Metric {
34 name: "reserved_bytes",
35 help: "Bytes the allocator reserved from the operating system",
36 kind: Kind::Gauge,
37 read: |stats| stats.reserved_bytes,
38 },
39 Metric {
40 name: "pinned_bytes",
41 help: "Bytes of pinned reservations the allocator never purges",
42 kind: Kind::Gauge,
43 read: |stats| stats.pinned_bytes,
44 },
45 Metric {
46 name: "committed_bytes",
47 help: "Bytes the allocator currently has committed",
48 kind: Kind::Gauge,
49 read: |stats| stats.committed_bytes,
50 },
51 Metric {
52 name: "committed_peak_bytes",
53 help: "Peak bytes the allocator has had committed",
54 kind: Kind::Gauge,
55 read: |stats| stats.committed_peak_bytes,
56 },
57 Metric {
58 name: "allocated_bytes",
59 help: "Bytes handed out to callers, as of each thread's last statistics merge",
60 kind: Kind::Gauge,
61 read: |stats| stats.allocated_bytes,
62 },
63 Metric {
64 name: "pages",
65 help: "Allocator pages currently in use",
66 kind: Kind::Gauge,
67 read: |stats| stats.pages,
68 },
69 Metric {
70 name: "threads",
71 help: "Threads currently known to the allocator",
72 kind: Kind::Gauge,
73 read: |stats| stats.threads,
74 },
75 Metric {
76 name: "arenas",
77 help: "Arenas currently managed by the allocator",
78 kind: Kind::Gauge,
79 read: |stats| stats.arenas,
80 },
81 Metric {
82 name: "purged_bytes",
83 help: "Total bytes the allocator purged back to the operating system",
84 kind: Kind::Counter,
85 read: |stats| stats.purged_bytes,
86 },
87 Metric {
88 name: "purge_calls",
89 help: "Total purge operations performed by the allocator",
90 kind: Kind::Counter,
91 read: |stats| stats.purge_calls,
92 },
93 Metric {
94 name: "mmap_calls",
95 help: "Total memory mappings the allocator requested from the operating system",
96 kind: Kind::Counter,
97 read: |stats| stats.mmap_calls,
98 },
99 Metric {
100 name: "huge_allocations",
101 help: "Total allocations larger than the allocator's largest size class",
102 kind: Kind::Counter,
103 read: |stats| stats.huge_allocations,
104 },
105 Metric {
106 name: "huge_bytes",
107 help: "Total bytes of allocations larger than the allocator's largest size class",
108 kind: Kind::Counter,
109 read: |stats| stats.huge_bytes,
110 },
111];