[package]
name = "gunnar-stage"
description = "per-thread stage attribution: wall, CPU, allocation and peak-growth accounting for named stages of the serve path"
version = "1.1.1"
edition = "2021"
rust-version = "1.85"
license = "MIT OR Apache-2.0"
repository = "https://git.gunnar.rs/nordisk/edda"
# ZERO dependencies, for the same reason `gunnar-pktline` has none and for one
# more of its own.
#
# The reason it shares with pktline: this crate is reachable from the appliance
# graph (through `gunnar-wire`'s optional `stages` feature), and §2 of
# `.nornir/TOTAL-PROMPT.md` is a budget, not a preference.
#
# The reason that is its own: every fact this crate would want from the kernel —
# per-thread user/sys CPU, resident set size, allocation counts — needs either
# `libc` or a `/proc` read, and neither belongs in a crate a server links. So it
# takes them as **installed hooks** instead (`set_cpu_clock`, `set_rss_probe`,
# `note_alloc`). The measuring binary supplies them; it already has `libc` and a
# `#[global_allocator]` it is allowed to replace, and a server that never
# installs one pays a `fn` pointer load per stage boundary and gets zeros.
#
# That split is also what makes the numbers trustworthy under `cargo test`. The
# `#[global_allocator]` this repository wrote before counted **per process**
# while libtest runs cases on threads, so every count landed on whichever case
# happened to be running. Everything here is `thread_local!`, and
# `tests/attribution.rs::allocation_is_per_thread` proves two threads doing
# deliberately lopsided work inside the SAME stage are told apart: 1 000 000
# bytes and 3 must report as 1 000 003, where a process-wide counter reports
# 2 000 006.
[dependencies]
[lints.rust]
unsafe_code = "forbid"