soothfast
Annotate a function, get a checked benchmark. The output below is real, produced by this exact code on every CI run:
use measured;
rsi=70.51
Docs and performance work the same way. Both are written from the code and
checked against it on every build. Adding soothfast costs one runtime
dependency (linkme); everything else lives in the separate
cargo-soothfast binary.
How it works
cargo soothfast measure records perfcnt, callgrind, walltime and alloc
counts into a baseline. cargo soothfast gate fails CI as soon as a fresh
run regresses past a threshold. The <!-- soothfast:bind --> and
<!-- soothfast:claim --> markers tie markdown prose to that same run, so a
stale README fails CI instead of going unnoticed.
There is more than benchmarks here. Spec reconciliation, SDK generation, trend charts, changelog drafts and an agent-facing MCP server are all covered in the full guide.
Quick start
[]
= { = "0.1.0", = ["runner"] }
[[]]
= "soothfast"
= false
// benches/soothfast.rs
bench_main!;
// Checked claims: complexity verified by size sweep, alloc count exact.
// Route constant inputs through soothfast::keep or LLVM const-folds them away.
$ cargo soothfast measure -p mylib --save-baseline base # backends probe: perfcnt/callgrind/walltime/alloc
$ cargo soothfast gate -p mylib # vs baseline; exit 1 on regression
$ cargo soothfast gate -p mylib --against-ref origin/master --ratchet v1.0 # merge-base + ratchet
$ cargo soothfast docs gen-tests -p mylib # markdown blocks -> tests + capture examples
$ cargo soothfast docs capture -p mylib # run examples, splice real output into docs
$ cargo soothfast docs check -p mylib # binds + claims + generated-artifact manifest
$ cargo soothfast docs accept -p mylib # re-lock soothfast.lock after verifying prose
$ cargo soothfast spec check -p myserver # #[route] vs OpenAPI/GraphQL/MCP specs
$ cargo soothfast report render -p mylib # perf tables, trend SVGs, badges, llms.txt
$ cargo soothfast mcp -p mylib # agent-facing server on stdio
See the guide for gating thresholds, ratchets, the full bind/claim/capture syntax, and spec reconciliation.
Prose describing `sorted`. CI fails if the code changes under it.
Numbers in prose become gated facts.
Dogfood
CI runs soothfast on soothfast. Seven crates each carry a bench target measured into a fresh baseline on every build, and this README is checked against it. The sentences below are checked claims rather than comments:
Constant inputs and results route through soothfast::keep, the black_box
equivalent. Without it LLVM const-folds the measured body away, which is the
easiest way to measure nothing at all.
Registry fingerprinting (FNV-1a over the normalized token stream) never allocates.
Summary statistics, meaning median and MAD over a sample set, cost a handful of allocations per call. Eight is the gated ceiling.
Workspace
| Crate | Role |
|---|---|
soothfast |
User-facing facade: #[measured], keep, registry re-exports |
soothfast-macros |
Proc-macros |
soothfast-registry |
linkme distributed slices, stable IDs, FNV-1a fingerprints |
soothfast-measure |
Measurement engine + metric backends |
soothfast-docs |
rustdoc JSON ingestion, bind blocks, doc-test generation |
soothfast-spec |
Declared-surface reconciliation: OpenAPI/AsyncAPI/GraphQL/MCP |
soothfast-sdk |
Python and TypeScript client emitters, with optional embedded servers |
soothfast-report |
Renderers: perf tables, trend charts, changelogs, llms.txt |
soothfast-site |
The docs-site engine behind docs build |
cargo-soothfast |
The CLI: everything CI calls |