Skip to content

Lower Brotli default compression level to 4#238

Merged
loks0n merged 1 commit into0.34.xfrom
brotli-level-4
Apr 19, 2026
Merged

Lower Brotli default compression level to 4#238
loks0n merged 1 commit into0.34.xfrom
brotli-level-4

Conversation

@loks0n
Copy link
Copy Markdown
Contributor

@loks0n loks0n commented Apr 19, 2026

Summary

  • Brotli default lowered from library default (11, near-max) to 4 — a sensible, fast setting for an HTTP response path.
  • Added explicit Zstd default of 3 (matches the library default; set explicitly for clarity).
  • Audited GZIP and Deflate: no public level setter in utopia-php/compression 0.1.4, both use PHP default level 6 — left as-is.

New constants on Http:

  • COMPRESSION_BROTLI_LEVEL_DEFAULT = 4
  • COMPRESSION_ZSTD_LEVEL_DEFAULT = 3

Applied in Response::send() via instanceof checks against Brotli / Zstd after algorithm selection.

Test plan

  • composer check (phpstan) passes
  • composer test passes
  • Existing compression e2e tests still pass (response body decompresses correctly at the new level)

🤖 Generated with Claude Code

Brotli defaulted to level 11 (near-max), which is too slow for an HTTP
response path. Set a fast, HTTP-sensible default of 4 and add an
explicit Zstd default of 3. GZIP and Deflate have no public level
setter in utopia-php/compression 0.1.4, so their PHP defaults (6) are
left as-is.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 19, 2026

Greptile Summary

This PR lowers the Brotli compression level from the library default (11) to 4 for better HTTP response throughput, and explicitly sets Zstd to its library default of 3 for clarity. Two new constants are added to Http and applied in Response::send() via instanceof checks before calling compress().

Confidence Score: 5/5

Safe to merge — changes are minimal, well-scoped, and follow existing patterns in the codebase.

No logic errors or correctness issues found. The level values are within valid ranges for both algorithms, the instanceof guards are correct, setLevel is called before compress(), and the new constants follow the established COMPRESSION_MIN_SIZE_DEFAULT pattern. All remaining observations are P2 or below.

No files require special attention.

Important Files Changed

Filename Overview
src/Http/Http.php Adds COMPRESSION_BROTLI_LEVEL_DEFAULT = 4 and COMPRESSION_ZSTD_LEVEL_DEFAULT = 3 constants, following the existing COMPRESSION_MIN_SIZE_DEFAULT pattern.
src/Http/Response.php Applies the new compression level defaults in send() via instanceof checks on the selected algorithm before calling compress(); logic and ordering are correct.

Reviews (1): Last reviewed commit: "Lower Brotli default compression level t..." | Re-trigger Greptile

@loks0n loks0n merged commit 49a6bd3 into 0.34.x Apr 19, 2026
5 checks passed
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.

1 participant