Repository navigation
fix: three tier "minimums" AWS does not publish, and the 7.4% under every cost - #233
Merged
Merged
Conversation
…very cost MinObjectSize held 40 KB for GLACIER and DEEP_ARCHIVE and 128 KB for INTELLIGENT_TIERING. AWS publishes a minimum billable object size for three of the eight classes, and none of these is one of them: the storage class table says NA for both archive classes and None for Intelligent-Tiering. Two of the three wrong values are real AWS numbers used for the wrong thing, which is the harder error to see. The archive classes' 40 KB is per-object metadata billed *in addition* to the object; Intelligent-Tiering's 128 KB is the size below which an object is not monitored, not auto-tiered, and not charged the automation fee. A minimum and an overhead are arithmetically opposite, so they cannot share a field — a minimum replaces a smaller object's size, an overhead adds to it. Under a floor, compressing 30 KB to 10 KB saves nothing; under an overhead it saves every byte it removes. So the direction of every small-object recommendation was wrong on the two cheapest tiers. What kept it in place was that each wrong value carried a confident comment stating its reason — "40 KB minimum", "128 KB minimum for optimization". A number with a stated reason reads as a number somebody checked. The two real figures now have fields named for what they are, PerObjectOverheadBytes and MonitoringEligibilityBytes, and the 40 KB is split across the two rates AWS bills it at: 32 KB at the archive class's own rate, 8 KB at S3 Standard's. Summing first and pricing once at the archive rate understates that portion 23-fold, and on a 10 KB DEEP_ARCHIVE object it is 82% of the true total. ValidateWrite warns about the surcharge instead of refusing, because packing small files into one archive is a remedy available before the write and not after — the refusal itself is #154's subject and is unchanged here. calculateObjectCost was also 7.4% low on every figure it produced: it divided bytes by 2^30 to get GB in three places while AWS bills decimal GB, and awsrates.GBFromBytes, added for exactly this, had no callers outside its own package. The old test could not see it — it passed 1024*1024*1024, called it "1GB", and asserted 1.0 * CostPerGBMonth, which holds under both divisors because the test made the same choice the code did. A test that recomputes the implementation's formula agrees with it by construction. The seven subtests that replaced it assert hand-computed dollar literals, and their failure messages name the wrong-answer signatures — both verified by making the mutation, not predicted. TestTierSizeThresholdsMatchWhatAWSPublishes pins all eight classes with the AWS source URL in each failure message, in the shape of internal/awsrates/rates_aws_test.go. The rates there can be re-read from the live Pricing API; these thresholds are not published there, so a citation naming the page to open is the substitute. It also asserts the minimum and the overhead are mutually exclusive, since that exclusion is the invariant that broke. KB versus KiB is decided explicitly in a named constant block rather than left as a bare 128 * 1024. 1024 overstates both the floor and the surcharge by 2.4%, which is conservative in both directions, and this repository has been wrong about exactly this before in the other and more expensive direction. Closes #229
scttfrdmn
enabled auto-merge (squash)
August 3, 2026 02:07
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.
Closes #229.
StorageTiersrecorded aMinObjectSizefor six storage classes. Three of those values are AWS's published minimum billable object size. The other three are not minimums at all — the storage class comparison table lists min billable object size asNAfor both Glacier classes andNonefor Intelligent-Tiering.INTELLIGENT_TIERINGMinObjectSize: 128 KBMonitoringEligibilityBytes: 128 KBGLACIERMinObjectSize: 40 KBPerObjectOverheadBytes: 40 KBDEEP_ARCHIVEMinObjectSize: 40 KBPerObjectOverheadBytes: 40 KBTwo of the three wrong values are real AWS numbers used for the wrong thing, which is the harder error to see. A minimum and an overhead are arithmetically opposite, so they cannot share a field — a minimum replaces a smaller object's size, an overhead adds to it. Under a floor, compressing a 30 KB object to 10 KB saves nothing; under an overhead it saves every byte it removes. So the direction of every small-object recommendation was wrong on the two cheapest tiers.
What kept it in place is worth naming: each wrong value carried a confident comment stating its reason —
// 40 KB minimum,// 128 KB minimum for optimization. A number with a stated reason reads as a number somebody checked.The 40 KB is billed at two rates
32 KB at the archive class's own rate for the index Glacier maintains, 8 KB at the S3 Standard rate for the name and metadata S3 keeps so the object stays listable. Standard is $0.023/GB-month against Deep Archive's $0.00099, so summing first and pricing once at the archive rate understates that portion 23-fold — on a 10 KB
DEEP_ARCHIVEobject it is 82% of the true total.ArchiveOverheadreturns the split;calculateObjectCostprices each part at its own rate.ValidateWritenow warns about the surcharge rather than refusing, because packing small files into one archive is a remedy available before the write and not after. The refusal itself is #154's subject and is unchanged here.And a 7.4% error at the one site that turns these numbers into money
calculateObjectCostdivided bytes by 2³⁰ to get GB in three places while AWS bills decimal GB — andawsrates.GBFromBytes, added for exactly this, had no callers outside its own package.The old test could not see it. It passed
1024*1024*1024, called it "1GB", and asserted1.0 * CostPerGBMonth— an expectation that holds under both divisors, because the test made the same choice the code did. A test that recomputes the implementation's formula agrees with it by construction. The seven subtests that replaced it assert hand-computed dollar literals:Their failure messages name the wrong-answer signatures, both verified by making the mutation rather than predicted: $0.0000000406 means the 40 KB is a minimum again, $0.0000000507 means the 8 KB is priced at the archive rate.
The pin test #229 asked for
TestTierSizeThresholdsMatchWhatAWSPublishescovers all eight classes — not the fourTestStorageTierscovers — with the AWS source URL in every failure message, in the shape ofinternal/awsrates/rates_aws_test.go. The rates there can be re-read from the live Pricing API; these thresholds are not published there, so a citation naming the page to open is the substitute. It also asserts every class admitted byawsnamehas an expectation, and that the minimum and the overhead are mutually exclusive — that exclusion is the invariant that broke, since the 40 KB sat inMinObjectSizebecause there was no other field for it.KB versus KiB is now decided in a named constant block rather than left as a bare
128 * 1024. 1024 overstates both the floor and the surcharge by 2.4%, conservative in both directions, and the comment records that this repository has been wrong about exactly this before in the other and more expensive direction.Verification
go test -race ./...— all packages passgolangci-lint run --new-from-merge-base=origin/main— 0 issuesDEEP_ARCHIVE'sMinObjectSizefails 4 assertions across both test files, each citing the AWS page. Restoring passes.docs/features/compression.mdhad a forward reference to this issue saying the table "encodes today" the wrong values — updated, since it would otherwise be stale on merge.