Skip to content

C0-4: Separate S3 object compression from write-buffer compression #157

Closed

Description

@scttfrdmn

Summary

buildS3Config feeds the write-buffer compression settings into the S3 object
compression config. They are two unrelated features with different defaults, so every mount
silently compresses S3 objects with gzip level 6 instead of the intended zstd level 3.

Background

internal/adapter/adapter.go buildS3Config:

Compression: s3.CompressionConfig{
    Enabled:   a.config.WriteBuffer.Compression.Enabled,
    Algorithm: a.config.WriteBuffer.Compression.Algorithm,
    Level:     a.config.WriteBuffer.Compression.Level,
    MinSize:   a.config.WriteBuffer.Compression.MinSize,
},

WriteBuffer.Compression defaults in internal/config/config.go to gzip / level 6 / 1KB —
tuned for buffering writes in memory. s3.NewDefaultConfig intends something quite
different for objects at rest:

Compression: CompressionConfig{
    Enabled:   true,
    Algorithm: "zstd",
    Level:     3,     // fast level with good ratio (~60% savings for text/JSON)
    MinSize:   "4KB", // skip compression for tiny objects
},

Consequences: objects are stored gzip instead of zstd, at a slower level with a worse ratio,
and the 1KB floor means tiny objects get compressed when the S3 path deliberately skips
them. Changing write-buffer tuning also silently changes the on-disk format of stored
objects, which is not a relationship anyone would expect.

Implementation

Add a dedicated Storage.S3.Compression section to internal/config/config.go, defaulting
to zstd / 3 / 4KB to match s3.NewDefaultConfig. Map that through buildS3Config and leave
WriteBuffer.Compression untouched for its own purpose.

Document the split in configs/example.yaml so the two sections are visibly distinct.

Worth calling out in the changelog: mounts that relied on the accidental gzip behavior will
begin writing zstd. Reads are unaffected — GetObject dispatches on the stored
Content-Encoding per object, so existing gzip objects continue to decompress correctly.
There is no migration.

Acceptance Criteria

  • Storage.S3.Compression exists and defaults to zstd / level 3 / 4KB
  • buildS3Config() yields zstd/3/4KB, not gzip/6/1KB
  • Changing WriteBuffer.Compression no longer affects the S3 object compression config
  • Previously-written gzip objects still read back correctly
  • configs/example.yaml documents both sections and the difference between them
  • go test -race ./internal/adapter/... ./internal/config/... passes

Dependencies

None. Should land together with the parallel-read plumbing issue — both rewrite
buildS3Config.

Activity

  1. added
    type: bug
    priority: high
    area: compression
    on Jul 29, 2026
  2. added
    effort: medium
    on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compressioneffort: mediumpriority: hightype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions