Repository navigation
feat(compression): frame compressed uploads and record a seekable descriptor (#185 stage 2) - #513
Merged
Merged
Conversation
…ptor (#185) Stage 2 of #185: the write path. A zstd object spanning more than one frame is now stored framed — a leading skippable frame carrying the index, then the content frames — and the object gains an `objectfs-seekable` metadata key holding version/frameSize/frameCount/indexLength so a reader can fetch the index in one correctly-sized request. No read gets faster in this commit, deliberately. The read path still decodes the whole stored body; framing is landing on its own because it changes the stored bytes of every compressible object a mount writes, and that has to be proven correct through the *unchanged* reader before anything is built on it. A framed object is a legal zstd stream — the index rides in a skippable frame every conformant decoder ignores — so the existing whole-object path, checkFullyDecoded and verifyChecksum all work untouched, which is what makes the split safe rather than a half-feature. Three things worth calling out. No config flag. Framing is chosen automatically for zstd above one frame and declined in five ordinary cases (compression off, non-zstd codec, below MinSize, already-compressed content, framed body no smaller than the input). The trade is stored size — under 1% on data with read locality, ~20% on self-similar text at the 256 KiB floor — against up to four orders of magnitude of read amplification. That is a decision worth making once here rather than a knob whose wrong value is invisible in both directions. The ratio estimator samples three windows, not a prefix. Its first form trial-encoded the first 1 MiB, and the doc comment claimed the ratio had to be wrong by 4x before DeriveFrameSize's answer moved. Measured: a file with an incompressible header came out 15x off and one with a compressible header 5x off — two powers of two of frame size, past what F's square root absorbs. Head/middle/tail for the same total encode cost brings the worst case to 0.49x on the ratio, 0.70x on the frame size. Both cases are now table rows. The xattr budget drops 1758 -> 1694. The 64 bytes are the descriptor's widest form, reserved on every object whether or not it is framed, and derived from compression.MaxSeekableDescriptorLen rather than written down. S3 rejects an over-budget metadata write instead of truncating it, so a reservation that is only usually right becomes a setfattr that succeeds and a flush that fails. The ratio test derives frame sizes at synthetic sizes {1 GiB..1 TiB} rather than at the fixture's own size. At any size a test can allocate, DeriveFrameSize clamps to MinFrameSize and every ratio in the table — right or wrong by 15x — produces exactly 262144, so the first version of that test was comparing two constants. TestDeriveFrameSizeVariesOverTheSizesTheRatioTestUses is the guard against that returning silently.
A mutation run disabled ParseSeekableDescriptor's version check entirely and TestParseSeekableDescriptorRejectsGarbage still passed. The cause was a wrong number, copied twice. The table hard-coded an index length of 2648, taken from this file's own doc-comment example. 2648 is not the consistent index length for 64 frames -- skippableHeaderSize + indexPayloadLen(64) is 2664 -- so the self-consistency check rejected those rows before any of them reached the check they were named for. The `unknown version` row was therefore proving nothing about versions, and `index length disagrees with frame count` was off by 16 rather than by one. Fixed in three places and structurally rather than by correcting the constant: - Every row now carries a substring of the error it must produce, so a row that is rejected for the wrong reason fails. This is the class of defect a table of rejections is most prone to, because every wrong reason is still a rejection. - The index lengths are computed from indexPayloadLen, not written down, and the two that are about the index length say so (off by one, and correct-for-65). - The doc comment's example is now a consistent descriptor, with a note that the number is load-bearing, since that comment is where the wrong one came from. The backend test's caller-supplied value is now a named constant holding a well-formed descriptor for a different object, which is the stronger adversary: a malformed one would be caught by the reader's parse even with the ownership filter removed.
`go vet -tags=integration ./...` failed with `undefined: itoa`. The helper is declared in skip_compressed_bench_test.go, which carries `//go:build !integration`; descriptor_test.go carries no constraint of its own, so it compiled under every combination CI actually reached on this branch and none of the ones it did not. Nothing local caught it. `go test -race ./...`, per-package coverage, and golangci-lint at both 2.12.2 and 2.13.2 all exercise exactly one cell of the tag matrix, and a test file's own build tags say nothing about what its dependencies require. CI would have caught it in `build-tags (integration)`, except that this PR is based on a feature branch and ci.yml filters `pull_request` to `branches: [main]`, so it ran no jobs at all — filed as #512. Refs #185
This was referenced Sep 16, 2026
scttfrdmn
added a commit
that referenced
this pull request
Sep 17, 2026
…ver existed (#523) The next release is 0.15.0, not the 0.16.0 the milestone was titled. Four lines in the Unreleased section described the CargoShip upload-path removal as having happened "in v0.15.0" — it shipped in 0.12.0 (#362, 2026-08-08) — and CLAUDE.md repeated the claim. A fifth said a tier defect was "the v0.15.0 defect"; that one was v0.10.1. No v0.15.0 tag, changelog section, or module-proxy entry has ever existed, so the number is free and skipping it would have preserved five wrong references to justify a milestone title. Promotes Unreleased to [0.15.0] - 2026-09-17: seekable compression framing end to end (#185, via #509/#513/#516) and the GoReleaser convergence (#502) with what it let us delete. Bumps the version constant, which is the authority the changelog link test and the packaging tests read. Also corrects the signing claims across four documents (#505). README.md, docs/index.md and docs-platform/guide/getting-started.md all said the project "does not sign releases yet"; #501 signs checksums.txt keylessly with cosign. Each now states the two positions separately, because neither covers the other: the release is signed, the .deb and .rpm files are not. The verify command is the one release.yml both runs and prints into the notes — a bundle, not the --certificate/--signature pair a first draft of this invented. README's claim that the apt/yum repository is "built and tested on every pull request" also went with #520, which deleted that machinery.
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.
Stage 2 of #185: the write path. Stage 1 (#509) is merged, so this targets
maindirectly andthe diff is stage 2 alone.
What this does
Compressed uploads are now emitted as a sequence of independent zstd frames with a leading index,
and the backend records a fixed-size descriptor of that layout in S3 user metadata under
objectfs-seekable.No read gets faster in this PR. The read path is stage 3. What this stage buys is that objects
written from now on are seekable when that lands, instead of needing a rewrite.
Why it is safe to ship ahead of the reader
A framed object is an ordinary zstd stream. The index is a skippable frame, so a plain decode walks
straight past it: this backend's existing whole-object path,
checkFullyDecoded,verifyChecksum,aws s3 cpandzstd -dall decode a framed object byte for byte with no changes. That is asserteddirectly —
TestFramedUploadStoresADescriptorThatDescribesTheObjectreads a framed object backthrough the unmodified whole-object path and compares.
The descriptor
version/frameSize/frameCount/indexLength, e.g.1/262144/16/744— 15 bytes typical, 36 at thewidest possible value. It is an accelerator, never the authority: the index inside the object is.
A
SetObjectMetadata(CopyObject withMetadataDirective=REPLACE) discards every key it does notrestate, and the caller doing a chmod is
internal/vfs, which knows nothing about framing. So thedescriptor is in
backendOwnedMetaKeysalongside the checksum and original size — a caller's valueis dropped silently rather than rejected (a caller round-tripping metadata from HeadObject must still
be able to write), and the object's own value is restated on every rewrite. If it is ever lost
anyway, the cost is one round trip, not a correctness problem.
No configuration flag
Framing engages or it doesn't, on measurable properties of the object. The five declines:
compression itself declined; the object is one frame or smaller; the framed body came out no smaller
than the input; the frame count would exceed the format's limit; the object is below the compression
minimum.
Frame size is
sqrt(40 * size * ratio)clamped to [256 KiB, 16 MiB] — the index-record cost againstthe read-amplification cost. Because
Fgoes as the square root of the ratio, the ratio estimatehas to be wrong by 4x to move
Fby one power-of-two step, which is what makes a sampled estimateviable at all. The sample is three windows, not a prefix: prefix-only sampling got a 1 MiB
incompressible head wrong by 0.19x and a 1 MiB compressible head by 15x — about two powers of two of
frame size. Both cases are permanent regression rows in
TestEstimateRatioIsCloseEnoughForDeriveFrameSize.The cost is stored size, and it is real
Independent frames mean no cross-frame back-references. Under a mixed workload with read locality
the loss is under 1%; on self-similar text at the 256 KiB floor it can reach ~20%. The CHANGELOG
entry says so plainly rather than quoting only the good number.
Also
internal/vfsreserves
MaxSeekableDescriptorLenagainst the format's wire widths (uint32 per field), notagainst the current policy limits — a policy limit can be relaxed in a patch release, a wire width
cannot change without a format version. README updated in both places.
TestParseSeekableDescriptorRejectsGarbagenow asserts which check rejected each row. The firstversion hardcoded an index length of 2648, copied from this file's own doc-comment example which
was itself wrong; 2664 is the consistent length for 64 frames, so a dozen rows were being rejected
by the self-consistency check before reaching the check they were named for. A mutation that
disabled the version check entirely left the test green. A table of rejections is the test shape
most prone to passing for the wrong reason, because every wrong reason is still a rejection.
Verification
go test -race ./internal/compression/ ./internal/vfs/ ./internal/storage/s3/— okMaxSeekableDescriptorLen's derivation,DescribeFrameIndex's frame count, prefix-vs-three-windowsampling, both framing declines, descriptor storage, backend ownership, and the xattr reservation
--new-from-merge-base(which caught fourmisspellfindings local 2.13.2 passed), gosec matches.github/gosec-baseline.txtexactlyinternal/testaws: descriptor↔object agreement, 9 ranged reads overframe boundaries, three declines, caller-write refusal, chmod survival
Deliberately not in this milestone
A real
0xEZstandard Seekable Format seek table for third-party interop. Recorded as a decision,not an oversight.
Refs #185
Verification, repeated from #511
Run locally against the pre-rebase tree, then re-run after rebasing onto
main(
go build ./...,go vet -tags=integration ./...,-raceover the three packages — all clean).testgo test -race ./...— no failureslint--new-from-merge-base— 0 issuesSecurity Scan.github/gosec-baseline.txt— 12 findings, 8 (rule, file) groups, matches exactlycoverageinternal/compression94.0% (floor 90),internal/vfs98.5% (98),internal/storage/s387.3% (81)build-tags×7go vet -tags=foraws_s3 benchmark distributed e2e integration fuse_mount s3compat— all okcross-build×6CGO_ENABLED=0build +go vetfor linux/{amd64,arm64,arm7,386} and darwin/{amd64,arm64} — all okThose coverage figures are measured over the three packages alone, so they exclude cross-package
contributions and are a lower bound on CI's number — above the floors either way, but not a substitute
for CI's measurement.
The
build-tags (integration)cell is why the third commit exists.itoais declared inskip_compressed_bench_test.go, behind//go:build !integration;descriptor_test.gohas noconstraint of its own and called it, so
go vet -tags=integration ./...failed withundefined: itoawhile-raceover the whole repo, coverage, both golangci-lint versions, and a10/10 mutation run were all green. They exercise one cell of the tag matrix. #511 ran no CI at all
because ci.yml filters
pull_requesttobranches: [main]— filed as #512, and this PR does not havethat problem.
Mutation: 10/10 caught, tree restored clean.