Skip to content

fix: three tier "minimums" AWS does not publish, and the 7.4% under every cost - #233

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/229-tier-min-object-size
Aug 3, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/229-tier-min-object-size

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #229.

StorageTiers recorded a MinObjectSize for 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 as NA for both Glacier classes and None for Intelligent-Tiering.

tier before after what AWS publishes
INTELLIGENT_TIERING MinObjectSize: 128 KB MonitoringEligibilityBytes: 128 KB no minimum; 128 KB bounds monitoring
GLACIER MinObjectSize: 40 KB PerObjectOverheadBytes: 40 KB no minimum; 40 KB is added metadata
DEEP_ARCHIVE MinObjectSize: 40 KB PerObjectOverheadBytes: 40 KB no minimum; 40 KB is added metadata

Two 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_ARCHIVE object it is 82% of the true total. ArchiveOverhead returns the split; calculateObjectCost prices each part at its own rate.

ValidateWrite now 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

calculateObjectCost divided bytes by 2³⁰ 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 — 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:

one decimal GB in Standard                                        $0.023
one binary GiB in Standard costs 7.4% more than a GB              $0.024696061952
a 64 KB object in Standard-IA is billed at the 128 KB minimum     $0.0000016384
the minimum does not raise an object already above it             $0.0000131072
a small Deep Archive object pays its bytes plus the 40 KB overhead $0.00000023099392
the overhead is a surcharge, so a larger object pays it too       $0.00000125894656
Intelligent-Tiering has no minimum, so a small object is billed for its bytes $0.00000023552

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

TestTierSizeThresholdsMatchWhatAWSPublishes covers all eight classes — not the four TestStorageTiers covers — with the AWS source URL in every 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 every class admitted by awsname has an expectation, and that the minimum and the overhead are mutually exclusive — that exclusion is the invariant that broke, since the 40 KB sat in MinObjectSize because 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 pass
  • golangci-lint run --new-from-merge-base=origin/main — 0 issues
  • Mutation test: putting the 40 KB back into DEEP_ARCHIVE's MinObjectSize fails 4 assertions across both test files, each citing the AWS page. Restoring passes.
  • docs/features/compression.md had a forward reference to this issue saying the table "encodes today" the wrong values — updated, since it would otherwise be stale on merge.

…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
scttfrdmn enabled auto-merge (squash) August 3, 2026 02:07
@scttfrdmn scttfrdmn added type: bug Something isn't working as expected priority: medium Important but not urgent labels Aug 3, 2026
@scttfrdmn scttfrdmn added area: s3 S3 backend integration and operations area: metadata Metadata management and inode operations labels Aug 3, 2026
@scttfrdmn
scttfrdmn merged commit dcae9f2 into main Aug 3, 2026
27 checks passed
@scttfrdmn
scttfrdmn deleted the fix/229-tier-min-object-size branch September 20, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: metadata Metadata management and inode operations area: s3 S3 backend integration and operations priority: medium Important but not urgent type: bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two of the tier MinObjectSize values are not AWS minimums: GLACIER/DEEP_ARCHIVE have none, INTELLIGENT_TIERING has none

1 participant