refactor(BA-6927): rename usage_bucket_entries.amount to resource_usage#12968
Closed
jopemachine wants to merge 2 commits into
Closed
refactor(BA-6927): rename usage_bucket_entries.amount to resource_usage#12968jopemachine wants to merge 2 commits into
jopemachine wants to merge 2 commits into
Conversation
jopemachine
added a commit
that referenced
this pull request
Jul 20, 2026
The original PR was opened with the wrong head branch and reopened as #12968. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4 tasks
FairShareAggregator accumulated the raw resource amounts and the slice durations of a bucket separately and multiplied them afterwards, yielding (sum amount_k) * (sum duration_k) instead of sum(amount_k * duration_k). The cross product inflates a bucket by the number of kernel slices folded into it, so a user running 4 GPU kernels saw 4x their real fGPU-seconds. The factor compounds up the hierarchy, since each level aggregates the kernels of everything beneath it. BucketDelta.slots becomes resource_usage -- it no longer holds an allocation but the allocation already integrated over the slice, which is what every other carrier of this quantity is called (the resource_usage column on kernel_usage_records and on all three bucket tables). Naming it resource_seconds would have put it next to duration_seconds and read as a second duration. The three repository call sites no longer re-multiply by the accumulated duration. usage_bucket_entries.amount widens to 32 digits: it stores a daily total per entity, and a domain-level mem bucket on a large cluster exceeds the previous 1e18 ceiling. Existing buckets cannot be corrected in place, in either the JSONB mirror or the normalized entries, so the migration rebuilds both from kernel_usage_records, which stores per-slice resource-seconds and was never affected. The oldest retained day is excluded because retention purges kernel records by period_end and may have truncated it; buckets older than the kernel record retention window keep their inflated values rather than being silently zeroed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jopemachine
force-pushed
the
fix/BA-6927-usage-bucket-cross-product
branch
from
July 20, 2026 04:56
81f0067 to
2d41a41
Compare
The column holds resource-seconds, not a resource amount. Under the old name `amount * duration_seconds` reads like the quantity a caller wants, when both columns are already sums and their product is a cross product -- the same shape as the bug fixed in the parent commit. resource_usage is what kernel_usage_records and the three parent bucket tables already call this quantity, so the entries table now speaks the same vocabulary rather than introducing a second name for one concept. Mechanical rename across the ORM model, the two repository read paths and the tests, plus the alembic column rename. No behaviour change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jopemachine
force-pushed
the
refactor/BA-6927-rename-resource-seconds
branch
from
July 20, 2026 04:59
6a17147 to
8f0ed08
Compare
jopemachine
force-pushed
the
fix/BA-6927-usage-bucket-cross-product
branch
from
July 20, 2026 05:01
2d41a41 to
aceb7db
Compare
Member
Author
|
Folded into #12965. The rename was split out while it was |
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.
📚 Stacked PRs
BA-6927fix: stop cross-multiplying usage bucket amounts and durationsBA-6927refactor: rename usage_bucket_entries.amount to resource_usage ← you are hereMerge in order, bottom-up. Each PR is based on the one above it, so its diff shows only its own layer.
Summary
usage_bucket_entries.amounttoresource_usage. The column holds resource-seconds, not a resource amount, and under the old nameamount * duration_secondsreads like the quantity a caller wants — when both columns are already sums and their product is a cross product, which is exactly the shape of the bug fixed in fix(BA-6927): stop cross-multiplying usage bucket amounts and durations #12965.resource_usageis whatkernel_usage_recordsand the three parent bucket tables already call this quantity, so the entries table now speaks the same vocabulary instead of introducing a second name for one concept.resource_usage_historyandfair_share) and the tests, plus an alembic column rename. No behaviour change.resource_usageJSONB rather than these entries.Test plan
pants test tests/unit/manager/repositories/resource_usage_history/ tests/unit/manager/repositories/retention/pants fmt/fix/lintpass on the changeset;pants check(mypy) cleanrepositories/{resource_usage_history,fair_share,retention}references the columnResolves BA-6927
🤖 Generated with Claude Code