Repository navigation
Conversation
…ytes `set_packed_keys` query ClickHouse#1 (keys64 `(UInt32, UInt32) IN (subquery)`) runs about 22% slower in a few percent of arm PR binaries, on every run of that binary. All extra time is in `Set::executeImplCase<SetMethodKeysFixed<keys64>>`, whose code is identical in every build. Its per-row loop keeps `LastElementCache` (empty@0, found@1, misses@8, value@16) on the stack and on every miss writes `misses` and `value` with one 16-byte `stp` at an offset that is 8 mod 16. Whether that store crosses a cache line is decided by unrelated code (caller stack depth, static TLS size); all slow CI builds have the crossing placement. Put `misses` first and keep `value` at +16 via `alignas(max(alignof(Value), 8))`, so every `LastElementCache` keeps its size, alignment and `value`/`is_null` offsets. Align the cache member to 16 only in states with `consecutive_keys_optimization`, so states without the cache (join key getters, key8/key16 sets) keep their exact layout. `misses` and `value` are no longer adjacent, and each per-row store is an aligned 8-byte store or a 16-byte store at a 16-aligned address. aarch64 objects, master vs this change: the keys64 probe's `stp x17, x10, [sp, #0x88]` becomes `str x17, [sp, #0x90]` and `str x10, [sp, #0xa0]`; one-pair `misses`+`value` stores go 17 -> 0 in Set.cpp.o and 149 -> 0 in Aggregator.cpp.o; HashJoin.cpp.o is byte-identical. 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 findings over 2 passes) plus my own review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261011-223400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261011-211700 |
|
Workflow [PR], commit [9fe99ed] Summary: ❌
AI ReviewSummaryThis PR reorders Final Verdict
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes48 object files changed (+44.23 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units471 translation units recompiled, 4914 s compile time in total, 471 of them have a recent master baseline. |
Picks up ClickHouse#125292, the fix for test_copy_of_temporary_table_under_unrelated_name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - d50226aEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261012-140015 |
CI finish ledger - 9fe99edEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261013-020010 |
Related: #112928
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
set_packed_keysquery #1 (a keys64(UInt32, UInt32) INprobe) runs about 22% slower in a few percent of arm PR binaries since 2026-10-10, on every run of the binary: 8 of 330 PR runs, 0 of 58 master runs, e.g. #112928 perf 3/6, where it is the only slower query.All extra samples are in
Set::executeImplCase<SetMethodKeysFixed<...UInt64...>>, whose machine code is identical in every such build. Its per-row loop keeps the consecutive-keys cache on the stack and, on every miss, writesmissesandvaluewith one 16-bytestpat an offset that is 8 mod 16. Whether that store crosses a cache line depends on unrelated code (caller stack depth, static TLS size). Of the 37 CI arm binaries with this code that I inspected, the 16 where it does not cross are all fast; of the 21 where it crosses, the 7 slow ones are exactly those whose frame lands at one particular stack position.The change puts
missesfirst inLastElementCacheBase, keepsvalueat its offset withalignas(max(alignof(Value), 8)), and aligns the cache member to 16 bytes only in states that use the cache. Each per-row store is then an aligned 8-byte store or a 16-byte store at a 16-aligned address. States without the cache (join key getters,key8/key16sets) keep their exact layout.Validation on aarch64 objects, master vs this PR: the keys64 probe's
stp x17, x10, [sp, #0x88]becomesstr x17, [sp, #0x90]+str x10, [sp, #0xa0]; pairedmisses+valuestores go 17 -> 0 inSet.cpp.oand 149 -> 0 inAggregator.cpp.o;HashJoin.cpp.ois byte-identical. 267 stateless tests pass. I have no arm hardware and this PR's reference build is usually fast, so the removal of the slow mode is inferred, not measured; arm PR runs after merge will show it.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125280]