Skip to content

feat: add --compression flag (default off) to control Accept-Encoding#17

Merged
paveg merged 1 commit into
mainfrom
feat/compression-opt-in
Apr 10, 2026
Merged

feat: add --compression flag (default off) to control Accept-Encoding#17
paveg merged 1 commit into
mainfrom
feat/compression-opt-in

Conversation

@paveg
Copy link
Copy Markdown
Owner

@paveg paveg commented Apr 10, 2026

Summary

  • Add opt-in --compression CLI flag (default off).
  • When off, inject Accept-Encoding: identity so response_size_bytes reflects wire bytes, matching pre-0.1.8 semantics for compressible targets.
  • When on, fall through to async 0.17.1's default gzip handling for realistic benchmarking of compressed endpoints.
  • User-provided Accept-Encoding via -H is honored and never overwritten.

Rationale

molt 0.1.8 pulled in moonbitlang/async 0.17.1, which started sending Accept-Encoding: gzip by default and transparently decompressing responses. That shifted response_size_bytes from wire bytes to decompressed payload size — a surprising regression for users who care about bandwidth measurement.

The behavior matches curl (which does not send Accept-Encoding unless you pass --compressed). It's an opt-in rather than opt-out because wire-byte measurement is the conservative default for a load testing tool.

Implementation

  • New compression : Bool field on Config (default false).
  • --compression wired through src/cmd/main/cli.mbt.
  • build_headers in src/lib/worker/worker.mbt injects Accept-Encoding: identity when compression=false and the user hasn't already set their own.
  • Debug path in src/cmd/main/main.mbt applies the same logic.
  • All Config literal construction sites updated.

Test plan

  • Whitebox tests for build_headers covering: compression off (injects identity), compression on (passthrough), user-provided Accept-Encoding preserved.
  • moon check --target native clean
  • moon fmt clean
  • moon test --target native — all tests pass (250 -> 254)
  • moon build --target native --release — binary builds

Closes #14

molt 0.1.8 inherited automatic gzip handling from async 0.17.1, which
silently shifted response_size_bytes from wire bytes to decompressed
bytes for targets that honor Accept-Encoding: gzip. That is surprising
for a load testing tool whose users typically want to measure wire
bandwidth.

Add an opt-in --compression flag (default off). When off, molt injects
Accept-Encoding: identity into every request so responses come back
uncompressed and response_size_bytes matches wire bytes again. When on,
users get async's default gzip handling for realistic compressed-
endpoint benchmarking.

User-provided Accept-Encoding headers (via -H) are honored and never
overwritten.

Closes #14

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.46%. Comparing base (75361f8) to head (8e77f7b).

Files with missing lines Patch % Lines
src/cmd/main/main.mbt 0.00% 2 Missing ⚠️
src/lib/worker/worker.mbt 66.66% 2 Missing ⚠️
src/cmd/main/cli.mbt 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #17      +/-   ##
==========================================
- Coverage   62.48%   62.46%   -0.02%     
==========================================
  Files          16       16              
  Lines         733      738       +5     
==========================================
+ Hits          458      461       +3     
- Misses        275      277       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paveg paveg merged commit 0eb84ee into main Apr 10, 2026
4 checks passed
@paveg paveg deleted the feat/compression-opt-in branch April 10, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

measurement: gzip auto-decompression in async 0.17.1 may skew response_size_bytes

2 participants