jcp: count the joules a cache hit did not spend, without ever calling it spend #75
Loading…
Reference in a new issue
No description provided.
Delete branch "jcp/avoided-energy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
MCP's 2026-07-28 revision added
CacheableResultwithttlMs/cacheScope, so a served result can declare itself reusable. When it is reused, work that would have run did not — and for a family whose doctrine is that inference is the last resort, the cheapest joule is the one never spent. Nothing in the family bound a reused result to an energy figure.It is also the easiest quantity here to lie with, so it deliberately does not become another
Energy.It is a counterfactual, not a measurement
Nothing measures a joule that was not spent. An avoided figure is a claim about what would have happened, and the only thing making it checkable is a pointer to the execution it stands in for.
So
AvoidedEnergycannot be constructed without naming the receipt whose measured cost it claims to have avoided. Without that, "this hit saved 10 mJ" is unfalsifiable — and unfalsifiable savings are how an efficiency programme reports progress it never made.It must never be added to energy spent
If avoided joules were summed with spent joules, or subtracted from them, a system could manufacture arbitrary efficiency and, with enough hits, report negative consumption.
So this type produces no
Energy, offers no arithmetic against a spend total, andAvoidedSummary::saving_ppm_oftakes the spend as an argument rather than holding it — the two totals meet in exactly one place, expressed as a ratio to spend and never a deduction from it. A test drives five million-microjoule hits against a 200 µJ spend and shows there is no path to a negative spend figure.A cache hit is not free
The net subtracts what serving the hit cost, since claiming the full prior cost over-claims by exactly that amount. When a lookup costs more than recomputing would have, the saving is reported negative rather than clamped — a cache that doesn't pay for itself is a real outcome, and rounding it to "no saving" hides the one case an operator most needs to act on.
unprofitable_hitsis counted separately, so a cache that is net-positive overall while losing on most requests is visible rather than averaged away.The saving inherits the basis measurement's acquisition class, because a saving standing in for an
Estimatorfigure is an estimated saving, however precisely it prints.Provenance
Ranked by the 2026-08-29 sweep as the one remaining item it called unclaimed territory rather than an adapter.
Verification
265 jcp-rs tests pass (5 new) · conformance passes all classes · no clippy warnings in the new file.
🤖 Generated with Claude Code