Repository navigation
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 PR runs no CI.
The coverage numbers are measured over the three packages alone, so they exclude cross-package The absent CI was not hypothetical
That is one real defect found by a job this PR does not run, on a diff that had already passed a Mutation10/10 caught, and the tree restored clean afterwards: The second row is the one worth naming. It survived the first run: |
|
Closed as a side effect of merging #509 with Reopened as #513 against |
ci.yml and security.yml both filtered their pull_request trigger on `branches: [main]`, so a pull request stacked on a feature branch started none of their jobs — not test, not lint, not coverage, not Security Scan, not one of the twelve build-tags/cross-build cells. Nothing failed, and that is what made it invisible for as long as it lasted. The checks never existed, so `gh pr checks` returned one row, `dependabot skipping`, and the pull request read as green because nothing was red rather than because anything had passed. #511 was reviewed in that state. The window also closes at exactly the moment it stops being useful. GitHub retargets a stacked pull request to main when its parent merges, so CI first runs after review has already happened against zero signal — the gap is invisible while it matters and gone by the time anyone would look. security.yml is not named in #512 but carried the same filter, and it matters more there: Security Scan is a required status check on main, so the filtered-out trigger was a check that is supposed to be able to block a merge and could not report at all. The push trigger keeps its `branches: [main]` in both files. That one is a different question with a correct answer — it stops a feature-branch push from duplicating the pull request's own run — so it is left alone rather than removed for symmetry. TestNoPullRequestTriggerFiltersItsBaseBranch walks .github/workflows/ and fails on a branches or branches-ignore filter under pull_request or pull_request_target. Walked rather than enumerated on purpose: naming the two files that had the bug checks the two files that had the bug, and the next workflow to arrive with `branches: [main]` copied out of a README is the case a hard-coded list cannot see. It carries a floor on the file count and a non-vacuity guard on the trigger count, the latter because yaml.v2 parses the key `on` as the boolean true — a map[string]any lookup finds nothing and passes every file.
Stage 2 of #185: the write path. Stacked on #509 (
feat/seekable-zstd-frame-format) — that PRhas to merge first, and this PR's base is set to its branch so the diff shown here is only stage 2.
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