Repository navigation
Conversation
Since the release builds became position independent executables (ClickHouse#117449, re-landed by ClickHouse#119284), the kernel loads the executable at a random address on every start, and in some processes some hot loops run 15-40% slower depending on that address. A restart of the same binary redraws it. In the Performance Comparison jobs, whichever server draws a slow placement looks like a regression, so unrelated PRs are flagged on both architectures (for example `logical_functions_small` ClickHouse#15 on arm, `decimal_parse` #0 and `join_squashing_blocks` #0 on amd), and users' servers of these releases draw the same start-dependent speed. The share of master-vs-master comparisons with one server more than 10% slower follows the PIE commits on unchanged hardware (m7i.4xlarge / m8g.4xlarge): arm `logical_functions_small` ClickHouse#15 1/342 before, 0/118 while the revert was in, 65/643 after the re-land; amd `decimal_parse` #0 0/589, 1/213, 177/1105. Restore the `NOT ENABLE_THINLTO` condition, so `amd_release`, `arm_release` and `amd_cfi` fall through to the existing `-fno-pie` / `-no-pie` branch. Every other amd64 and aarch64 build keeps `-fPIC` and `-pie`, so the file offset stack traces keep being exercised on PIE images by the debug and sanitizer jobs; for an `ET_EXEC` image the main object's load address is 0, so the stored offset equals the link-time address and resolves as before. The compatibility check now asserts that the packaged release binary is `ET_EXEC`, so the relocation model stays guarded. The trade-off: the release binaries' own code is no longer subject to ASLR (heap, stack, mmap and shared libraries still are). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pendent # Conflicts: # CMakeLists.txt
Release builds with ENABLE_THINLTO get no -flto=thin (it is only added to the RelWithDebInfo flags), so they keep -fPIC and -pie as on master. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 rounds, 2 findings in round 1, 0 in round 2) plus my own review.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261011-224000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261011-222900 |
|
Workflow [PR], commit [6804dd0] Summary: ✅
AI ReviewSummaryThis PR restores non-PIE linking for the actual ThinLTO Final Verdict
|
-flto=thin is added only when ENABLE_THINLTO is set without ENABLE_TESTS and SANITIZE, and only to the RelWithDebInfo flags. With FAIL_ON_UNSUPPORTED_OPTIONS_COMBINATION=OFF, a configure such as ENABLE_THINLTO=1 ENABLE_TESTS=1 only warns "Cannot enable ThinLTO", and the carve-out still dropped -pie/-fPIC although nothing was built with LTO. Use the same predicate as the -flto=thin block. Configure-only check: the CI amd_release, arm_release and Release+ThinLTO build graphs are identical to the previous commit; the ThinLTO+tests and ThinLTO+ASan configs with FAIL_ON_UNSUPPORTED_OPTIONS_COMBINATION=OFF are identical to master again (-pie -Wl,-pie -fPIC). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing Binary sizes
|
| Binary | Master | PR | Δ |
|---|---|---|---|
programs/clickhouse-stripped |
785.50 MiB | 747.98 MiB | -37.52 MiB (-4.78%) |
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.
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
16047 object files changed (+3.39 MiB total), 0 added.
| Object file | Master | PR | Δ |
|---|---|---|---|
contrib/hive-metastore-cmake/CMakeFiles/_hivemetastore.dir/__/hive-metastore/ThriftHiveMetastore.cp… |
5.69 MiB | 5.82 MiB | +134.79 KiB (+2.32%) |
contrib/google-cloud-cpp-cmake/CMakeFiles/google_cloud_cpp_storage_protos.dir/google/storage/v2/sto… |
1.71 MiB | 1.75 MiB | +44.55 KiB (+2.55%) |
contrib/google-protobuf-cmake/CMakeFiles/_libprotobuf.dir/__/google-protobuf/src/google/protobuf/co… |
339.96 KiB | 378.15 KiB | +38.19 KiB (+11.23%) |
contrib/vectorscan-cmake/CMakeFiles/_vectorscan.dir/__/vectorscan/src/rose/rose_build_program.cpp.o |
698.62 KiB | 732.56 KiB | +33.94 KiB (+4.86%) |
contrib/arrow-cmake/CMakeFiles/_parquet.dir/__/arrow/cpp/src/generated/parquet_types.cpp.o |
987.15 KiB | 1018.02 KiB | +30.87 KiB (+3.13%) |
base/poco/Foundation/CMakeFiles/_poco_foundation.dir/src/Exception.cpp.o |
328.03 KiB | 356.80 KiB | +28.77 KiB (+8.77%) |
contrib/libhdfs3-cmake/CMakeFiles/_hdfs3.dir/ClientNamenodeProtocol.pb.cc.o |
1.05 MiB | 1.07 MiB | +24.22 KiB (+2.26%) |
contrib/icu-cmake/CMakeFiles/_icui18n.dir/__/icu/icu4c/source/i18n/messageformat2_data_model.cpp.o |
168.89 KiB | 192.73 KiB | +23.83 KiB (+14.11%) |
src/CMakeFiles/dbms.dir/Interpreters/ActionsDAG.cpp.o |
1.33 MiB | 1.35 MiB | +22.02 KiB (+1.62%) |
contrib/icu-cmake/CMakeFiles/_icui18n.dir/__/icu/icu4c/source/i18n/number_fluent.cpp.o |
104.31 KiB | 124.84 KiB | +20.53 KiB (+19.68%) |
contrib/llvm-project-cmake/CMakeFiles/LLVMAnalysis.dir/__/llvm-project/llvm/lib/Analysis/ScalarEvol… |
1.30 MiB | 1.32 MiB | +18.72 KiB (+1.40%) |
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeData.cpp.o |
4.24 MiB | 4.25 MiB | +18.57 KiB (+0.43%) |
contrib/llvm-project-cmake/CMakeFiles/LLVMCore.dir/__/llvm-project/llvm/lib/IR/ConstantRange.cpp.o |
257.03 KiB | 273.71 KiB | +16.68 KiB (+6.49%) |
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
16204 translation units recompiled, 33297 s compile time in total, 15698 of them have a recent master baseline.
| Translation unit | Master | PR | Δ vs median |
|---|---|---|---|
contrib/aws-cmake/__/aws/generated/src/aws-cpp-sdk-s3/source/S3Client.cpp |
19.9 s | 13.7 s | -6.2 s (-31%) |
contrib/grpc-cmake/__/grpc/src/core/client_channel/client_channel.cc |
6.7 s | 12.7 s | +6.1 s (+91%) |
contrib/grpc-cmake/__/grpc/src/core/filter/fused_filters.cc |
7.0 s | 12.9 s | +5.9 s (+85%) |
contrib/grpc-cmake/__/grpc/src/core/ext/transport/chttp2/transport/frame_settings.cc |
5.2 s | 11.1 s | +5.8 s (+112%) |
contrib/grpc-cmake/__/grpc/src/core/xds/grpc/xds_listener_parser.cc |
6.0 s | 11.5 s | +5.5 s (+91%) |
contrib/grpc-cmake/__/grpc/src/core/call/server_call.cc |
5.4 s | 10.6 s | +5.3 s (+98%) |
contrib/grpc-cmake/__/grpc/src/core/ext/transport/chttp2/transport/http2_client_transport.cc |
10.6 s | 15.7 s | +5.1 s (+48%) |
Slowest changed entities of contrib/grpc-cmake/__/grpc/src/core/filter/fused_filters.cc:
- InstantiateFunction
grpc_core::MakePromiseBasedFilter<grpc_core::filters_detail::FusedFilter<grpc_core::FilterEndpoint:…: +0.6 s (+238%) - InstantiateFunction
grpc_core::promise_filter_detail::ChannelFilterWithFlagsMethods<grpc_core::filters_detail::FusedFil…: +0.6 s (+239%) - InstantiateFunction
grpc_core::filters_detail::FusedFilter<grpc_core::FilterEndpoint::kClient, '\r', grpc_core::ClientA…: +0.6 s (+239%)
Symbol sizes ⚠️
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse-keeper |
_ZZN24TopLevelDomainLookupHash7isValidEPKcmE8wordlist |
864.07 KiB | removed | -864.07 KiB (-100.00%) |
programs/clickhouse |
_ZZN24TopLevelDomainLookupHash7isValidEPKcmE8wordlist |
864.07 KiB | removed | -864.07 KiB (-100.00%) |
programs/clickhouse-keeper |
wordlist |
242.38 KiB | removed | -242.38 KiB (-100.00%) |
programs/clickhouse |
wordlist |
242.38 KiB | removed | -242.38 KiB (-100.00%) |
programs/clickhouse |
rd_kafka_properties |
131.25 KiB | removed | -131.25 KiB (-100.00%) |
programs/clickhouse |
_ZGRN2DB12_GLOBAL__N_15nounsE_ |
102.33 KiB | removed | -102.33 KiB (-100.00%) |
programs/clickhouse-keeper |
_ZGRN2DB12_GLOBAL__N_15nounsE_ |
102.33 KiB | removed | -102.33 KiB (-100.00%) |
programs/clickhouse |
a_2 |
82.50 KiB | removed | -82.50 KiB (-100.00%) |
programs/clickhouse-keeper |
a_2 |
82.50 KiB | removed | -82.50 KiB (-100.00%) |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
randomString filled its offsets with IColumn::getUInt, an indirect call per row. In this PR's position dependent amd_release binary that loop crosses a 64-byte boundary (master's PIE build and the position dependent master of 2026-09-07 keep it inside one line), and Performance Comparison measured random_string #0/ClickHouse#1/ClickHouse#4/ClickHouse#5 0.03-0.04 s slower per 100M rows on Sapphire Rapids, ClickHouse#4 by 23%. Integer and constant lengths are now read directly, so the loop has no call; floats, decimals and wide integers keep getUInt. Results and errors are unchanged for every length type. On Granite Rapids random_string ClickHouse#4 takes 0.54x and #0 0.35x of the time of the master build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano
left a comment
There was a problem hiding this comment.
@groeneai THis is a horrible PR. Breaking security features just so you can forget about some performance investigations is definitely not ok.
|
You are right, trading ASLR for quieter perf comparisons was the wrong call. The release binaries stay PIE; I will investigate why some PIE server processes run these queries slower and fix the cause instead. |
|
Here is what I found. The slowdown follows the alignment of the code relative to 2 MiB, and PIE draws that alignment again at every server start. On arm (Graviton4, kernel 6.8) the server is a PIE with 64 KiB segment alignment, so its load base is random in 64 KiB steps (gcd of 1866 measured bases:
Before PIE the binary was position dependent, so this alignment was fixed per build. I have not identified which structure in the core is sensitive to these address bits. It is not huge pages. Two ways to remove the per-start draw:
I recommend 2. @Algunenano, should I send 1 or 2? A separate x86 observation: the comparison remaps the text onto huge pages, and since PIE the second server's text is only partly on huge pages in 74% of runs (0 of 35 before PIE). In 70 one-sided amd |
Let's do this. |
|
Acknowledged. I will send the 2 MiB segment alignment for the release binaries as a new PR and link it here. |
|
Fixing PR: #125949 |
|
@groeneai follow-up to this investigation and to the "Let's do this" for 2 MiB segment alignment. We want to keep the release binaries PIE and remove the load-address-dependent slowdowns. Please open a PR against
And please report, in the PR description:
|
|
@groeneai please hold: do not open a PR for this request for now. We will follow up here when it should proceed. |
|
The request above moved to #127892; please ignore it here. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The amd64 and aarch64 Linux release builds are linked as position dependent executables again, as before 26.9. As position independent executables, some queries ran 15-40% slower in some server processes, depending on the address the binary was loaded at. The code of these binaries is no longer subject to ASLR; the heap, stack and shared libraries still are.
randomStringwith short strings is up to 2.9x faster.Description
Related: #122447
Since #117449 / #119284 the ThinLTO builds (
amd_release,arm_release,amd_cfi) are PIE, so the executable is loaded at a random address on every start. In some processes some hot loops run 15-40% slower. Performance Comparison reports whichever side drew a slow placement as a regression on unrelated PRs, for examplelogical_functions_small#15 on #111932. Servers running a 26.9 release can draw the same start-dependent speed.Master-vs-master comparisons with one server more than 10% slower, on unchanged hardware
logical_functions_small#15multiif#1decimal_parse#0join_squashing_blocks#0This restores the pre-#117449 carve-out for the builds that get
-flto=thin(ENABLE_THINLTOwith RelWithDebInfo, without tests or sanitizers), so these three builds fall through to the existing-fno-pie/-no-piebranch. Every other build keeps-fPICand-pie, so the file-offset stack traces stay exercised on PIE images.Compatibility checknow asserts the packaged binary isET_EXEC.randomStringread its length through a virtualgetUIntper row; in this PR'samd_releasebinary that loop crossed a 64-byte boundary andrandom_string#4 was 23% slower. It now reads integer and constant lengths directly: locally #4 takes 0.54x and #0 0.35x of master's time.Validation: an
amd_releasebuild isET_EXECand loads at0x200000on 12 of 12 starts; the 25 stateless tests that use stack traces and symbols pass on it; the new check passes onET_EXECand fails on the PIE builds.Trade-off: the release binaries' own code loses ASLR. If you prefer to keep PIE, close this and I will make the harness confirm these rows instead.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125278]