Skip to content

Apply http_zlib_compression_level only to zlib-based HTTP compression - #125899

Merged
alexey-milovidov merged 3 commits into
masterfrom
http-zlib-level-only-for-zlib
Oct 16, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
http-zlib-level-only-for-zlib

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

The HTTP handler passed http_zlib_compression_level to every response compression method (both from Accept-Encoding with enable_http_compression = 1 and from the compression setting), including zstd, lz4, xz, br and bz2. These methods have their own ranges and meanings of levels: for example, lz4 switches to the slow high-compression mode starting from level 2, and level 12 (valid for zlib with libdeflate) makes xz fail with lzma preset failed, so the request returns HTTP 500.

Now http_zlib_compression_level applies only to gzip and deflate. Other methods use output_format_compression_level, the generic setting for the level of compressed query output. Both settings default to 3, so the default behavior does not change.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The setting http_zlib_compression_level now applies only to the gzip and deflate HTTP response compression. The level of other methods (zstd, lz4, br, xz, bz2) is controlled by output_format_compression_level. Previously, a level suitable for zlib was passed to every method, which could make lz4 unexpectedly slow or make xz fail.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/125899]

Version info

  • Merged into: 26.11.1.97-master (included in 26.11 and later)
  • Backported to: 26.10.2.10, 26.9.21.6, 26.8.30.5, 26.7.33.4, 26.3.54.6

alexey-milovidov and others added 2 commits October 14, 2026 22:27
The HTTP handler passed `http_zlib_compression_level` to every response
compression method, including `zstd`, `lz4`, `xz`, `br` and `bz2`, which have
their own ranges and meanings of levels. For example, `lz4` switches to the slow
high-compression mode starting from level 2, and level 12 (valid for zlib with
`libdeflate`) is invalid for `xz`.

Now `http_zlib_compression_level` applies only to `gzip` and `deflate`, and
other methods use `output_format_compression_level`. Both default to 3, so the
default behavior does not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b2efe91]

Summary: ✅


AI Review

Summary

This PR restricts http_zlib_compression_level to gzip and deflate responses and uses output_format_compression_level for other codecs in both HTTP compression paths. No actionable findings. The added regression test passed in the Fast test report.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-protocols Server wire protocols + request/response handling (native TCP, HTTP, MySQL/PostgreSQL wire protoc... labels Oct 14, 2026
@alexey-milovidov alexey-milovidov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Oct 14, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@clickhouse-gh

clickhouse-gh Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing b2efe917d with master a21868cbd (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of e5791b213; compile times per translation unit against the most recent warmup build that recompiled it).

⚠️ Significant changes: object file sizes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes ⚠️

1056 object files changed (-2.75 MiB total), 4 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/DataTypes/TypeFunctions.cpp.o new 1.00 MiB +1.00 MiB
src/CMakeFiles/dbms.dir/Interpreters/Aggregator.cpp.o 25.56 MiB 26.43 MiB +895.89 KiB (+3.42%)
src/CMakeFiles/dbms.dir/DataTypes/TypeMatchers.cpp.o new 692.78 KiB +692.78 KiB
src/CMakeFiles/dbms.dir/DataTypes/FunctionSignature.cpp.o new 417.14 KiB +417.14 KiB
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayDotProduct.cpp.o 1.75 MiB 1.55 MiB -201.52 KiB (-11.24%)
src/CMakeFiles/dbms.dir/Functions/FunctionsConversion_impl2.cpp.o 1.31 MiB 1.14 MiB -174.78 KiB (-13.07%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsBitmap.cpp.o 2.58 MiB 2.41 MiB -167.40 KiB (-6.35%)
src/CMakeFiles/dbms.dir/Functions/FunctionsConversion_impl1.cpp.o 1.12 MiB 986.07 KiB -160.78 KiB (-14.02%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/vectorFunctions.cpp.o 3.29 MiB 3.43 MiB +148.59 KiB (+4.41%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayCumSumNonNegative.cpp.o 603.16 KiB 466.82 KiB -136.34 KiB (-22.60%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayCumSum.cpp.o 673.15 KiB 538.16 KiB -134.99 KiB (-20.05%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayAggregation.cpp.o 1.29 MiB 1.16 MiB -134.86 KiB (-10.22%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsCodingIP.cpp.o 1.27 MiB 1.13 MiB -133.67 KiB (-10.32%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayDifference.cpp.o 592.61 KiB 478.04 KiB -114.56 KiB (-19.33%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsJSON.cpp.o 4.26 MiB 4.37 MiB +111.80 KiB (+2.57%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsHashingMisc.cpp.o 5.53 MiB 5.61 MiB +83.25 KiB (+1.47%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/arrayDistance.cpp.o 10.19 MiB 10.11 MiB -78.98 KiB (-0.76%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsConversion_reg.cpp.o 6.83 MiB 6.75 MiB -78.39 KiB (-1.12%)
src/CMakeFiles/dbms.dir/Functions/FunctionsConversion_impl3.cpp.o 1.87 MiB 1.80 MiB -76.37 KiB (-3.98%)
src/CMakeFiles/dbms.dir/Functions/IFunction.cpp.o 555.11 KiB 631.16 KiB +76.05 KiB (+13.70%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

2853 translation units recompiled, 15691 s compile time in total, 2848 of them have a recent master baseline.

Translation units without a recent master baseline:

  • programs/keeper/Keeper.cpp (clickhouse-keeper): 7.7 s
  • src/DataTypes/TypeFunctions.cpp: 6.5 s

Job report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 16, 2026
Merged via the queue into master with commit 0e1ef1b Oct 16, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the http-zlib-level-only-for-zlib branch October 16, 2026 18:50
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 16, 2026
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 16, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 16, 2026
Backport #125899 to 26.9: Apply `http_zlib_compression_level` only to zlib-based HTTP compression
clickhouse-gh Bot added a commit that referenced this pull request Oct 16, 2026
Backport #125899 to 26.8: Apply `http_zlib_compression_level` only to zlib-based HTTP compression
alexey-milovidov added a commit that referenced this pull request Oct 17, 2026
Keep only the change of `HTTPHandler::processQuery` that selects the level by compression method
(`http_zlib_compression_level` for `gzip` and `deflate`, `output_format_compression_level` otherwise).
The generic response compression from the `compression` setting and `snappy_mode` do not exist in 26.3,
and the `http_zlib_compression_level` documentation keeps the 26.3 range of possible values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robot-ch-test-poll4 added a commit that referenced this pull request Oct 17, 2026
Cherry pick #125899 to 26.3: Apply `http_zlib_compression_level` only to zlib-based HTTP compression
robot-clickhouse added a commit that referenced this pull request Oct 17, 2026
alexey-milovidov added a commit that referenced this pull request Oct 17, 2026
Keep only the change of `HTTPHandler::processQuery` that selects the level by compression method
(`http_zlib_compression_level` for `gzip` and `deflate`, `output_format_compression_level` otherwise).
The generic response compression from the `compression` setting does not exist in 26.7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robot-clickhouse-ci-2 added a commit that referenced this pull request Oct 17, 2026
Cherry pick #125899 to 26.7: Apply `http_zlib_compression_level` only to zlib-based HTTP compression
robot-clickhouse added a commit that referenced this pull request Oct 17, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 17, 2026
alexey-milovidov added a commit that referenced this pull request Oct 17, 2026
Backport #125899 to 26.3: Apply `http_zlib_compression_level` only to zlib-based HTTP compression
clickhouse-gh Bot added a commit that referenced this pull request Oct 17, 2026
Backport #125899 to 26.7: Apply `http_zlib_compression_level` only to zlib-based HTTP compression
clickhouse-gh Bot added a commit that referenced this pull request Oct 18, 2026
Backport #125899 to 26.10: Apply `http_zlib_compression_level` only to zlib-based HTTP compression
alexey-milovidov pushed a commit to bacek/ClickHouse that referenced this pull request Oct 19, 2026
ClickHouse#125899 linked `output_format_compression_level` and `http_zlib_compression_level`
to each other with in-page `#anchor` links. The two settings are rendered into
different generated settings families (format settings and session settings).
The docs generator resolves an in-page setting anchor only against the routes of
the current family, so an anchor of the other family falls back to that family's
catch-all `other` page, which does not contain it. The daily docs regeneration
PR (ClickHouse#126475) then fails `Check internal links and anchors`:

    reference/settings/formats/other#http_zlib_compression_level | Cannot find fragment
    reference/settings/session-settings/other#output_format_compression_level | Cannot find fragment

Link to the absolute shard routes instead, as the existing cross-family links
already do (`min_insert_block_size_bytes` in FormatFactorySettings.h,
`input_format_json_named_tuples_as_objects` in Settings.cpp). The generator does
not rewrite a link that points into another family, so the routes are rendered
verbatim. Validated by regenerating the full docs tree with the patched binary
and running the CI lychee links check: 2 errors before, 0 after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
strtgbb pushed a commit to Altinity/ClickHouse that referenced this pull request Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-protocols Server wire protocols + request/response handling (native TCP, HTTP, MySQL/PostgreSQL wire protoc... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants