Repository navigation
Description
Summary
Compression defaults to off and is opt-in as of v0.10.1. There is no document telling a user when turning it on is a good idea. Three of the tradeoffs are genuinely non-obvious, and two of them can make compression a net loss — one in money, one in data accessibility.
This came out of a direct question: "project level compression and S3 native compression. While project level compression saves on bandwidth and end-to-end latency what else does it provide?" The answer is "less than you would think, and it costs you something real", which is exactly why it needs writing down.
What the doc has to cover
1. The tier billing minimum can eat the entire saving
S3 bills a minimum billable object size on several tiers, and it applies to the stored size:
| tier | billing minimum |
|---|---|
| STANDARD | none |
| STANDARD_IA, ONEZONE_IA, GLACIER_IR, INTELLIGENT_TIERING | 128 KB |
| GLACIER, DEEP_ARCHIVE | 40 KB |
So compressing a 100 KB file down to 40 KB on STANDARD_IA saves nothing — both are billed as 128 KB. You paid CPU on write, you pay CPU on every read, and the invoice is identical.
The worked examples need to show the crossover, not just state the rule. Compression only reduces the bill when the compressed size is above the tier minimum, which for STANDARD_IA means objects that compress to more than 128 KB. Below that, on those tiers, compression is a pure cost.
(Related: MinObjectSize in internal/storage/s3/tiers.go uses binary KB — 128 * 1024 — where AWS states these as decimal. Noted on #154.)
2. Exit integrity — a compressed object is not readable by anything else
This is the one that surprises people, and it is the most important thing in the document.
A zstd-compressed ObjectFS object is stored with Content-Encoding: zstd. aws s3 cp, boto3, the S3 console, and every other tool will hand you the compressed bytes. They will not decompress it. So the implicit guarantee that makes S3-backed storage attractive — "my data is just objects in a bucket, I can always get at it" — is void for compressed objects.
This deserves a prominent callout, not a footnote, because:
- It is invisible until someone needs it, which is usually during an incident or a migration.
- It affects downstream consumers who never touched ObjectFS: a Spark job, an
aws s3 syncto another bucket, a colleague with read access to the bucket. - The failure mode is not an error.
aws s3 cpsucceeds and writes a file. A.bamthat is silently a zstd frame fails later, somewhere else, in a way nobody traces back to this setting.
The doc should state plainly: enable compression only if every consumer of the bucket goes through ObjectFS, or is prepared to decode Content-Encoding: zstd itself.
3. Ranged reads of a compressed object fetch the whole object
zstd's default single-frame output must be decoded from the start, so a partial read cannot be served partially. The audit measured a 4 KiB read against real S3 in us-west-2: 15.6× penalty at 16 MiB, 43.0× at 64 MiB, 216.5× at 256 MiB — and it scales, so a 4 KiB read of a compressed 10 GiB object transfers 10 GiB.
For a sequential workload (cat, cp, a whole-file read) this is irrelevant. For random access — a database file, an indexed BAM, mmap'd data, an HDF5 file being read by chunk — it is disqualifying. That distinction is the single most useful sentence the document can offer.
#185 tracks seekable framing, which would fix this. Until it lands, the guidance is: do not enable compression on objects you read randomly.
4. What actually compresses
Most research data does not. internal/compression/analyzer.go already enumerates the formats that are compressed at the byte level: gzip, zstd, bzip2, lz4, xz, zip, PNG, JPEG, GIF, WebP, MP4, MKV, MP3 — plus, by content class, BAM/CRAM (BGZF), Parquet/ORC (per-column codecs), Zarr and HDF5 with filters, and any tar.zst/tar.gz.
What does compress: plain text, CSV/TSV, XML, JSON, YAML, source code, logs, uncompressed FASTA/FASTQ, uncompressed VCF, .tar without a codec, uncompressed NetCDF-3.
Worth being direct: for a typical genomics or imaging bucket, compression saves close to nothing because the data arrived compressed. The user should check before enabling, and the doc should say how (look at the extensions; or once #184 lands, ObjectFS will skip them automatically).
5. Project-level vs. S3-native — the actual answer to the question asked
There is no S3-native transparent compression. What people mean by that is usually one of:
Content-Encodingset at upload by another tool. Same tradeoffs as ObjectFS compression, minus the transparency: you get the compressed bytes back unless the client decodes.- S3 Select / Athena reading compressed objects. Query-side decompression for specific formats. Not general storage compression.
- Compression inside the file format (Parquet column codecs, BGZF, HDF5 filters). This is usually the right answer and the doc should say so: format-internal compression is seekable by design, portable, and understood by every tool that reads the format. ObjectFS-level compression is a worse version of it for any data that has the option.
So the honest guidance is: prefer format-internal compression where the format supports it. ObjectFS-level compression is for data whose format has no compression of its own and that you read whole.
6. What compression does not buy
Answering the question directly, since the premise was bandwidth and latency:
- It does not reduce request counts. Same number of GETs and PUTs; the billing minimums above mean it may not reduce request cost either.
- It does not help durability or integrity.
objectfs-sha256is recorded and verified regardless (backend.go:459-466). - It does not speed up writes. It costs CPU on the write path, and until Wire up the compression analyzer: ObjectFS re-compresses the formats research data is already stored in #184 lands it costs that CPU even on data that will not compress.
- It does add a failure mode: an object stored with an encoding this build cannot decode fails closed with an integrity error. That is the correct behavior — v0.10.0 returned the raw frame with exit status 0 — but it is a new way for a read to fail that an uncompressed object does not have.
Placement
docs/features/compression.md, linked from the README's configuration section and included in mkdocs.yml nav. It should be reachable from wherever compression.enabled is documented, because the moment a user finds that key is the moment they need this page.
Constraint
Every number in this document must be traceable. docs-platform/index.md:82-89 sets the standard after its hardcoded chart was removed: a page either names bucket, region, and object size, or it says nothing about throughput. The amplification figures above are real measurements against us-west-2 and should be cited with those parameters; the billing minimums are AWS-published and should link to the AWS pricing page rather than being restated as ObjectFS facts.
Activity