Expand description
Per-feature latency classification + manifest.
A recipe’s optional features are not all the same kind of thing: some change
the per-op hot path (a measured p99 claim), some are O(n) whole-structure ops
(serialize, compaction) that cannot honestly carry a per-op sub-ms number, and
some are pure capabilities with no latency delta (serde derives). This module
lets the bench decide the category from a size sweep, and merge-writes the
decision into a per-language manifest .subms/features/<lang>.json that the
website renders.
The manifest is a public contract: the merge preserves any fields the harness
does not own (yours, or another tool’s), touching only a feature’s perf
rating + p99ByStage. Zero-dependency: the JSON value model, parser and
serialiser here are hand-written, like the rest of the crate.
use subms::{SubMsFeatureCategory, classify_feature};
// A flat p99 across a 64x size sweep, well above the base op -> hot-path.
let sweep = [(1_024usize, 300u64), (65_536usize, 320u64)];
let (cat, _why) = classify_feature(&sweep, Some(50), None);
assert_eq!(cat, SubMsFeatureCategory::HotPath);
// p99 grows ~linearly with size -> structural (O(n)).
let sweep = [(1_024usize, 1_000u64), (65_536usize, 64_000u64)];
let (cat, _why) = classify_feature(&sweep, None, None);
assert_eq!(cat, SubMsFeatureCategory::Structural);Structs§
- SubMs
Feature Manifest - A per-language feature manifest (
.subms/features/<lang>.json). Wraps aJsonobject so a load/mutate/save round-trip preserves every field the harness does not own - only a feature’sperfrating +p99ByStageare set. - SubMs
Stage Class - One stage of a feature, classified on its own measurements.
Enums§
- Json
- A minimal JSON value. Objects keep insertion order (a
Vecof pairs, not a map) so a merge preserves the on-disk key order and any unknown fields. Numbers keep their literal text so large integer p99 values round-trip exactly. - SubMs
Feature Category - How a feature relates to the latency claim. The bench decides this from a size sweep; the string form is the manifest wire value + the UI enum.
- SubMs
P99Source - Which box a manifest’s
p99ByStagefigures were measured on.
Functions§
- classify_
feature - Decide a feature’s category from a size sweep of
(structure_size, p99_ns)measurements.base_p99_nsis the base op’s p99 for the no-delta check (None -> any flat, non-empty sweep reads as hot-path).override_categoryshort-circuits the decision for a genuinely ambiguous feature (amortized, borderline-flat O(log n)); the reason records that it was overridden. - parse_
json - Parse JSON text into a
Jsonvalue. Returns an error string on malformed input. Std-only recursive descent; enough for manifest documents. - roll_
up_ stages - Roll per-stage categories into the one a feature publishes.