Repository navigation
Description
Summary
The parallel-read fast path is gated on whether a compression codec is configured, not on whether
the object being read is compressed. So enabling compression silently disables parallel range GETs
for every object in the bucket, including objects that were never compressed and objects written by
other tools.
internal/storage/s3/backend.go:329-341:
threshold := b.config.ParallelReadThreshold
if threshold > 0 && (b.compressor == nil || !b.compressor.Enabled()) {
...
if readSize > threshold {
return b.parallelGetObject(ctx, key, offset, readSize)
}
}b.compressor.Enabled() reports the local write configuration. It says nothing about the object named
by key.
Why this is the residue of C4, not a new defect
Audit finding C4 was that the whole-object-versus-ranged decision was keyed on the compression config
rather than the object. That was fixed directly below this block — fetchOffset, fetchSize = offset, size
at :356, with the whole-object re-fetch happening only when the response comes back encoded, or when a
416 turns out to be a range past the end of a compressed body.
This gate is the same mistake one line above the fix, and it survived because it fails quietly. C4 moved
bytes that did not need moving, which a byte-count assertion catches. This one merely declines an
optimization, so nothing fails and nothing is logged.
The comment above it — "Skipped when transparent compression is active (whole-object decompress path must
remain intact)" — describes the correct intent. Skipping the fan-out for a compressed object is right:
there is nothing to fan out across, since the entire frame is needed to decode any of it. The bug is the
scope: it applies to the whole bucket.
Impact
On a mount with write_buffer.compression.enabled: true:
- Every read above
performance.parallel_read.threshold(default 64 MB) loses its fan-out, whatever the
object is. - A bucket where compression was enabled recently, or where it applies to a small subset of objects, pays
this on all of the rest. - It compounds with the fact that most research data does not compress at all (Wire up the compression analyzer: ObjectFS re-compresses the formats research data is already stored in #184): the objects that
gain nothing from compression are the same ones losing parallel reads because of it.
Not a correctness problem — reads return the right bytes either way. It is v0.10.0's headline feature
being switched off by an unrelated setting.
Fix
Decide from the object, the same way the ranged-versus-whole decision now does. The parallel path already
needs the object size for chunk arithmetic, and readSize <= 0 already triggers a HeadObject at :332-337
to get it. That response also carries the metadata that answers whether the object is compressed —
isCompressed(info.Metadata) exists and is already used at :400.
So for the case that already HEADs, this is free. For the case where the caller supplied a size, the
choice is between an extra HEAD and a cheaper heuristic:
- Attempt the fan-out and fall back if the first chunk returns a
Content-Encoding, mirroring the
re-fetch logic below. Costs one wasted chunk on compressed objects, which already pay a whole-object
fetch. - Or HEAD when compression is enabled and the caller gave a size. One extra cheap request on a read that
is by definition above 64 MB.
The first is preferable: it keeps the cost on the compressed objects rather than on every large read.
Acceptance criteria
- A read above the threshold of an uncompressed object fans out even with compression enabled
- A read above the threshold of a compressed object does not fan out, and returns correct bytes
- Test asserts the number and shape of GETs against the substrate endpoint, in the style of
internal/storage/s3/read_amplification_test.go— this is a request-count property, so a timing
assertion would be a proxy for it - A test that would have caught the original: same object, same read,
Compression.Enabledtoggled,
asserting the fan-out is unchanged
Provenance
Found while writing the compression guidance doc (#186), which has to tell users what enabling
compression costs. This was the third cost and it was not in the issue's list.
Activity
docs: what transparent compression costs, measured rather than assert…
perf(s3): probe the fan-out with one chunk instead of a full wave (#514…