Repository navigation
Net cache savings, and cost buckets split by model - #19
Merged
Merged
Conversation
Two changes the desktop overview needs. **The cache saving was gross, not net.** It counted what cache hits saved and never subtracted what cache writes cost extra — and writes are not free: a 5-minute cache write is 1.25x the input rate against a read's 0.1x. A workload that rebuilds its cache constantly and rarely hits it pays *more* than one with no caching at all, and the panel reported it as money saved. That is precisely the case a user needs to see, and the number was hiding it. It can now go negative, and a negative is a conclusion: caching is losing money on this workload. The break-even is low — the write premium is 0.25x and each read saves 0.9x, so reading back about 28% of what was written already pays for it. Three tests pin the arithmetic, including the loss case. **Cost buckets can be split by model or provider.** A trend chart and a composition chart answer two questions that belong together: when the money went, and what it went on. Read separately, the reader has to line up time between two pictures; stacked into one chart, both are a single glance. `cost_buckets_by` groups by (bucket, model) with the same bucket arithmetic as `cost_buckets` — a test asserts the two line up, because the caller fills empty buckets from a shared origin and being one grid off would draw real data in an empty slot. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks for the PR. One thing before review: this targets
No need to close and reopen: click Edit next to the PR title and change the base branch to See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two changes the desktop overview needs.
The cache saving was gross, not net
Prices::cache_savingcounted what cache hits saved and never subtracted what cache writes cost extra. Writes are not free — a 5-minute cache write is 1.25× the input rate, against a read's 0.1×. So a workload that rebuilds its cache constantly and rarely hits it pays more than one with no caching at all, and the panel reported it as money saved. That is exactly the case a user needs to see, and the number was hiding it.It can now go negative, and a negative is a conclusion rather than an edge case to clamp away. The break-even is low: the write premium is 0.25× and each read saves 0.9×, so reading back about 28% of what was written already pays for it. Three tests pin the arithmetic, including the loss case.
Note this changes the sign and magnitude of
cache_saved_microsinSummaryand on stored rows for future writes; existing rows keep whatever they were written with.Cost buckets split by model or provider
A trend chart and a composition chart answer two questions that belong together — when the money went, and what it went on. Read separately the viewer has to line up time across two pictures; stacked into one chart it is a single glance.
cost_buckets_bygroups by (bucket, model) using the same bucket arithmetic ascost_buckets, exposed atGET /summary/buckets/by?dim=model. A test asserts the two line up: the caller fills empty buckets from a shared origin, so being one grid off would paint real data into an empty slot.Gates
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace(61 binaries green),./scripts/smoke.sh(46 passed, 0 failed).🤖 Generated with Claude Code