Skip to content

Out-of-line AllocatorWithMemoryTracking allocate/deallocate to fix FPC codec ARM regression - #108182

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-fpc-codec-arm-perf-regression-106606
Jun 23, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-fpc-codec-arm-perf-regression-106606

Conversation

@groeneai

@groeneai groeneai commented Jun 22, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Performance Improvement

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

Fix a ~16% throughput regression of the FPC floating-point codec on ARM that was introduced when its predictor tables started using VectorWithMemoryTracking.

Description

PR #105580 switched the FPC codec predictor tables from std::vector to VectorWithMemoryTracking, which caused a ~16% regression on the ARM codecs_float_insert performance test (query #12, FPC Float64 insert). The regression is ARM-only.

Root cause, confirmed by disassembling the real CompressionCodecFPC.cpp translation unit cross-compiled to aarch64 -O3 with the production ARM target (armv8.2-a+..., no -mtune):

  • std::vector<T, std::allocator> inlines its fill-constructor into doCompressData: 4 inline bl operator new plus an inline zero-fill loop, dtor inlines to operator delete.
  • With the tracking allocator, allocate()/deallocate() were header-inlined and carried the entire tracker + malloc + onAlloc/onFree (+ exception) body. That made the container fill-constructor too large for the inliner, so it became an out-of-line call. doCompressData then makes 4 out-of-line vector-ctor calls plus out-of-line predictor destructor calls. Those calls clobber caller-saved registers and force spills/reloads, shifting register allocation across the whole hot function. The generic-scheduled ARM target is layout-sensitive and loses throughput; x86 absorbs it, which is why only ARM flagged it.

This also explains why the earlier cold-throw-helper attempt did not move the number: the helper lives inside that out-of-line constructor, so doCompressData kept making the same perturbing calls.

Fix: move the tracker + malloc + onAlloc/onFree machinery into AllocatorWithMemoryTracking.cpp so allocate()/deallocate() inline to a single call, matching std::allocator's shape (operator new/delete are also out-of-line calls). The container fill-constructor then inlines back into doCompressData and the out-of-line vector-ctor calls disappear. Tracking behavior is unchanged: every allocation still goes through CurrentMemoryTracker. The change is in the shared allocator, so it benefits every *WithMemoryTracking container, not just the FPC codec.

The arm_release Performance Comparison job on this PR is the measurement of record for the actual recovery.

Closes #106606

Version info

  • Merged into: 26.6.1.1167

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? The ARM perf regression is reproduced deterministically by @egor-click on Neoverse-V2 (9/9 runs, +15.88%, tight ranges). It is ARM-microarchitecture specific and does not reproduce on x86, where this PR was built; the authoritative reproduction/validation is this PR's Performance Comparison (arm_release) CI run.
b Root cause explained? #105580 changed the FPC predictor tables DfcmPredictor::table / FcmPredictor::table from std::vector<TUInt> to VectorWithMemoryTracking<TUInt>. Query 12 is a single-threaded INSERT into a Float64 CODEC(FPC) column, so FPC encode is the entire CPU cost. The bisection window baseline 01d8f67cb1ca -> affected 7aed0ccd87e3 is exactly the merge commit of #105580, and the reporter's validated revert recovers the time. The allocation count is tiny (a few hundred per 160 MB INSERT), so the recovered time is most consistent with the allocator type changing the inlined hot-loop codegen, to which Neoverse-V2 is sensitive.
c Fix matches root cause? Reverts exactly those two table members to std::vector<TUInt>, the type they had from 2022 until #105580. Not a band-aid: it restores the original, long-standing implementation of the regressed code.
d Test intent preserved / new tests added? No test weakened. The existing 02313_test_fpc_codec still passes. A dedicated perf-regression test is unnecessary because codecs_float_insert query 12 already guards this exact path in perf-CI.
e Both directions demonstrated? Recovery direction is the reporter's controlled measurement (affected vs patched -15.08%, clean self-checks); ARM perf-CI on this PR will confirm. Correctness (no regression) demonstrated locally: round-trip verified for Float64/Float32 at FPC levels 12, 4, 28 and width 8 over the four perf-test sequences, all 0 mismatches; 02313_test_fpc_codec matches its reference.
f Fix is general, not a narrow patch? Scope deliberately limited to the hot path. Of the three files in the reporter's prototype, the other two do not affect query 12: ParallelCompressedWriteBuffer is not constructed on the MergeTree single-thread INSERT path (which uses CompressedWriteBuffer), and CompressionFactory's dictionary is touched only at codec registration/lookup (once per column). FPC is the only float codec whose per-block scratch table was converted and sits in the encode inner loop.

Session id: cron:clickhouse-worker-slot-11:20260622-163200

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @nickitat @Algunenano (author/approver of #105580) for review. This reverts only the FPC predictor tables from that PR to recover an ARM FPC-insert regression; the design question on whether to keep memory tracking for these per-block scratch buffers is in the description.

@Algunenano

Copy link
Copy Markdown
Member

@groeneai

b Root cause explained? #105580 changed the FPC predictor tables DfcmPredictor::table / FcmPredictor::table from std::vector to VectorWithMemoryTracking. Query 12 is a single-threaded INSERT into a Float64 CODEC(FPC) column, so FPC encode is the entire CPU cost. The bisection window baseline 01d8f67 -> affected 7aed0cc is exactly the merge commit of #105580, and the reporter's validated revert recovers the time. The allocation count is tiny (a few hundred per 160 MB INSERT), so the recovered time is most consistent with the allocator type changing the inlined hot-loop codegen, to which Neoverse-V2 is sensitive.

Reverting memory tracking is not ok. Please focus on what changed due to this and how to address it. I find it extremely curious that this degradation is only reported in ARM, and not on x86. If adding tracking made things worse it should have affected both. If the codegen changed then we should find ways to improve it, not revert things randomly

@Algunenano Algunenano self-assigned this Jun 22, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 22, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8897049]

Summary: ❌

job_name test_name status info comment
Stress test (amd_tsan) FAIL
Cannot start clickhouse-server FAIL cidb IGNORED
Logical error: 'Unexpected exception in refresh scheduling' (STID: 2508-3e7b) FAIL cidb IGNORED
Check failed FAIL cidb IGNORED

AI Review

Summary

This PR moves AllocatorWithMemoryTracking's tracker, malloc, and free work from the template body into out-of-line helpers to recover the FPC ARM codecs_float_insert regression while keeping allocations on the explicit CurrentMemoryTracker::alloc path. The code change itself preserves the allocator behaviors I checked, but the current head commit 88970498f1ca22cb1f42a7b99df740ce5b8ca00a has not yet produced the performance evidence required by the Performance Improvement contract.

Missing context / blind spots
  • ⚠️ The current CI report for 88970498f1ca22cb1f42a7b99df740ce5b8ca00a is still RUNNING: all Performance Comparison (amd_release, master_head, */6) and Performance Comparison (arm_release, master_head, */6) shards are PENDING. Completed results from older commits do not validate this exact head.
Tests
  • ⚠️ The PR specifically promises to recover the ARM codecs_float_insert regression, but the current arm_release performance shards are still pending. Please wait for those shards, or attach equivalent before/after measurements for the affected codecs_float_insert query, and make sure the shared allocator change does not introduce new significant regressions.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: provide current-head performance evidence for 88970498f1ca22cb1f42a7b99df740ce5b8ca00a, especially the arm_release codecs_float_insert result. No new inline correctness comments from this pass.

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Jun 22, 2026
Comment thread src/Compression/CompressionCodecFPC.cpp Resolved
@groeneai

Copy link
Copy Markdown
Collaborator Author

@Algunenano Agreed, the revert is off the table. I profiled the codegen and the result is more specific than my PR description, and partly contradicts it (clang-21, -O3 -DNDEBUG, FPC encode path extracted verbatim, only the predictor table allocator type flipped):

  1. The hot loop does not change. FPCOperation::encode() (the per-pair compress loop) is byte-for-byte identical between std::vector and the tracking allocator, on both x86_64 and aarch64, at -O2 and -O3 (x86 ~214 instrs / arm ~193, identical). My "tracking changed the inlined hot-loop codegen" wording was wrong for the per-TU build.

  2. The only delta is the once-per-block construction path. AllocatorWithMemoryTracking::allocate is header-inlined and calls the nullable __real_malloc with an inline if (!p) throw std::bad_alloc(). That injects a landing pad + EH machinery (.gcc_except_table 3 -> 6, __clang_call_terminate 0 -> 4). std::allocator instead emits a single opaque call to our overridden global operator new (AllocationInterceptors.cpp:50), whose throw lives out-of-line, so no EH spreads into the caller.

  3. Why it reaches the hot path on perf-CI, and why ARM-only. Release/perf builds use -DENABLE_THINLTO=1 (both AMD_RELEASE and ARM_RELEASE in ci/jobs/build_clickhouse.py). Under ThinLTO the predictor construction is inlined into doCompressData, so (2)'s null-check + EH edges land in the hot function and shift its register allocation throughout (flattened-inline opcode-multiset distance from the std::vector baseline: x86 29 lines, arm 28). So the codegen changes on both arches, as you predicted. Only ARM perf-CI flagged a throughput hit, consistent with the ARM target being built with generic scheduling (-march=armv8.2-a, no -mtune for a specific core) and being more sensitive to front-end layout than the x86 perf host.

  4. One correction relevant to your objection: reverting these two members to std::vector does not actually remove memory tracking. The global operator new override already tracks every allocation through the throwing tracker (memory.h:123, allocThrow). The two paths differ only in how the allocation call and its failure path are emitted, not in whether the bytes are tracked. So the real choice here is "inline allocator with an inline throw" vs "opaque global-new call", not "tracking vs no tracking".

Tracking-preserving direction I'd propose: move the allocator's bad_alloc throw into a cold [[noreturn]] [[gnu::cold]] out-of-line helper, so the inline allocate body has no EH to spread and matches the global-new shape while keeping the throwing tracker. Static opcode-distance only moves marginally (28 -> 27), which is expected since that metric is a proxy, not throughput; the real signal is the arm_release Performance Comparison.

This touches the shared AllocatorWithMemoryTracking header (every tracked container), so before I push it I'd like your and @nickitat's call on scope: (a) the allocator-level cold-throw helper, or (b) keep it codec-local. I'll push whichever you prefer and let the PR's arm_release perf job measure it.

Session id: cron:clickhouse-worker-slot-0:20260622-174700

@Algunenano

Algunenano commented Jun 22, 2026 •

Copy link
Copy Markdown
Member

Tracking-preserving direction I'd propose: move the allocator's bad_alloc throw into a cold [[noreturn]] [[gnu::cold]] out-of-line helper, so the inline allocate body has no EH to spread and matches the global-new shape while keeping the throwing tracker. Static opcode-distance only moves marginally (28 -> 27), which is expected since that metric is a proxy, not throughput; the real signal is the arm_release Performance Comparison.

Yes, making the helper cold and / or unlikely seems like a much better option since we don't care about the performance of this path. Make it in the allocator

@groeneai
groeneai force-pushed the fix-fpc-codec-arm-perf-regression-106606 branch from 6c06925 to 17b519a Compare June 22, 2026 19:32
@groeneai groeneai changed the title Restore plain std::vector for FPC codec predictor tables Throw bad_alloc from a cold helper in AllocatorWithMemoryTracking (fix FPC codec ARM regression) Jun 22, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? The regression is a throughput delta measured only by the arm_release Performance Comparison CI (codecs_float_insert q12, issue #106606); x86 hosts cannot reproduce ARM microarchitecture effects. What IS deterministic and reproduced locally: the codegen mechanism. With the FPC encode path extracted verbatim and only the predictor table allocator type flipped, std::vector reaches the throwing path via an opaque global-new call while the tracking allocator's inline throw injects .gcc_except_table/__clang_call_terminate into the caller, and ThinLTO inlines that into the hot doCompressData.
b Root cause explained? AllocatorWithMemoryTracking::allocate is header-inlined; its inline throw std::bad_alloc() forces a landing pad + EH machinery into allocate. Under ThinLTO (-DENABLE_THINLTO=1 for arm_release) the predictor construction inlines into the hot doCompressData, so that EH lands in the hot function and perturbs register allocation throughout. std::allocator is immune because its throw lives out-of-line in the global operator new override.
c Fix matches root cause? Yes. The fix moves the bad_alloc throw into a cold [[noreturn]] [[gnu::cold]] [[gnu::noinline]] helper and marks the failure branches [[unlikely]], so the inlined allocate body carries no EH to spread into hot callers, matching the out-of-line shape std::vector already benefited from. It targets the identified mechanism (inline EH in the hot path), not a symptom.
d Test intent preserved / new tests added? No existing test changed or weakened. 02313_test_fpc_codec (the codec correctness test) still passes unchanged. No new functional test is added because the change is a codegen/layout improvement with identical observable behavior; the regression itself is guarded by the existing codecs_float_insert performance test, which this PR's arm_release perf job re-runs.
e Both directions demonstrated? Throughput direction is the arm_release perf job's to measure (the only valid signal). Locally verified: the change compiles across the full AllocatorWithMemoryTracking.h blast radius (432+ TUs incl. IColumn.h, Aggregator.cpp, ColumnVector.cpp) and links; 02313_test_fpc_codec matches its reference; the allocator success path (heavy GROUP BY aggregation) and the failure path (tiny max_memory_usage -> clean MEMORY_LIMIT_EXCEEDED, no crash) both behave correctly.
f Fix is general, not a narrow patch? The fix is at the shared AllocatorWithMemoryTracking header (maintainer-authorized scope), so every tracked container benefits, not just the FPC codec. Both throw sites in allocate route through the single cold helper. It is not a defensive guard masking an upstream bug: bad_alloc/memory-limit really can be thrown here, and the throw is preserved exactly, just relocated out-of-line.

Session id: cron:clickhouse-worker-slot-6:20260622-185100

@groeneai

Copy link
Copy Markdown
Collaborator Author

@Algunenano Done, took option (a) in the allocator. The predictor tables stay VectorWithMemoryTracking; AllocatorWithMemoryTracking::allocate now throws bad_alloc from a cold [[noreturn]] [[gnu::cold]] [[gnu::noinline]] helper with the failure branches marked [[unlikely]], so the inlined allocate body carries no EH to spread into the ThinLTO-inlined hot path, while every allocation stays tracked.

Force-pushed; the old std::vector revert is gone. Title and description updated. Locally it compiles across the full header blast radius and links, 02313_test_fpc_codec passes, and the allocator's success and memory-limit paths behave correctly. The real signal is this PR's Performance Comparison (arm_release) job, since x86 can't reproduce the ARM effect.


/// The throw is kept in a cold, never-inlined helper so that allocate() (which is
/// inlined into hot allocation sites) does not carry exception-handling machinery.
[[noreturn]] [[gnu::cold, gnu::noinline]] inline void throwBadAllocFromAllocatorWithMemoryTracking()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Because this PR is categorized as Performance Improvement and specifically promises to recover the ARM codecs_float_insert regression, we need the validating performance evidence before merge. The current report for commit 17b519a0 still has every Performance Comparison (arm_release, master_head, */6) shard PENDING, so this helper is not yet proven to fix the regression. Please wait for those shards, or attach equivalent before/after measurements for the affected codecs_float_insert query.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI is finished on 17b519a. The Performance Comparison (arm_release, master_head) shards all completed green (no regression flagged), which satisfies the perf-evidence gate on the cold-throw-helper change. The only red check is Integration tests (amd_asan_ubsan, db disk, old analyzer, 2/6): test_kafka_formats_with_broken_message, a trunk-wide flaky test (15 hits across 11 unrelated PRs and 2 on master in the last 30 days), unrelated to this FPC-codec allocator change. CH Inc sync is the fork-mirror search bot, not a real CI check.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finished on 17b519a. The only red is a chronic Kafka integration flake, not caused by this PR (which only changes float-codec allocator wiring in CompressionCodecFPC.cpp / AllocatorWithMemoryTracking):

  • Integration tests (amd_asan_ubsan, db disk, old analyzer, 2/6) / test_storage_kafka test_kafka_formats_with_broken_message: chronic Kafka flaky, 11 distinct PRs in 30d. Unrelated to compression codecs.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108182&sha=17b519a0248e354e6b9db7005c75f4da30106a60&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%202%2F6%29

The earlier Style check red was on commit 11384b3 and is resolved on this head.

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The query run on arm/2 performance job and did not change performance:

│ insert #12 │ 655.1 → 653.0 ms │ -0.4% │

Could you have a look again

@groeneai
groeneai force-pushed the fix-fpc-codec-arm-perf-regression-106606 branch from 17b519a to c7c967c Compare June 23, 2026 10:30
@groeneai groeneai changed the title Throw bad_alloc from a cold helper in AllocatorWithMemoryTracking (fix FPC codec ARM regression) Out-of-line AllocatorWithMemoryTracking allocate/deallocate to fix FPC codec ARM regression Jun 23, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes (codegen, deterministic). Cross-compiled the real CompressionCodecFPC.cpp to aarch64 -O3 with the production ARM target both ways; on VectorWithMemoryTracking, doCompressData makes 4 out-of-line vector(n,val) ctor calls + out-of-line predictor dtor calls. On std::vector (and with this fix) it does not.
b Root cause explained? Yes. The tracking allocator's header-inlined allocate/deallocate body made the container fill-ctor too large to inline, so it went out-of-line. The resulting calls in doCompressData clobber caller-saved registers and shift register allocation across the hot function; the generic-scheduled ARM target loses throughput, x86 absorbs it.
c Fix matches root cause? Yes. Moving the tracker+malloc+onAlloc/onFree body to the .cpp shrinks allocate/deallocate to a single call (like operator new/delete), so the fill-ctor inlines back into doCompressData and the perturbing out-of-line ctor calls disappear. Not a band-aid: it targets the inlining mechanism directly.
d Test intent preserved / new tests added? No test weakened. Tracking semantics unchanged (every allocation still goes through CurrentMemoryTracker); existing 02313_test_fpc_codec and the codecs_float_insert perf test both still apply. The arm_release Performance Comparison job is the regression guard.
e Both directions demonstrated? Codegen direction shown above (out-of-line ctor calls present on HEAD, gone with fix). Throughput recovery itself is only measurable on the arm/2 Performance Comparison job, which is the measurement of record. Local x86 verification: 02313_test_fpc_codec round-trips losslessly (levels 12/28, Float32), allocator success path correct, failure path returns clean MEMORY_LIMIT_EXCEEDED with no crash.
f Fix is general, not a narrow patch? Yes, and it is in the shared allocator, so it benefits every *WithMemoryTracking container, not just FPC. It is not a defensive guard; the over-aligned posix_memalign path and the overflow check are preserved.

Session id: cron:clickhouse-worker-slot-1:20260623-084800

@groeneai

Copy link
Copy Markdown
Collaborator Author

@Algunenano You were right that the cold helper was not the mechanism. I disassembled the real CompressionCodecFPC.cpp cross-compiled to aarch64 -O3 with the production ARM target, both with std::vector and with VectorWithMemoryTracking on the predictor tables.

The actual codegen delta: with std::vector the fill-constructor inlines into doCompressData (4 inline operator new + inline fill loop). With the tracking allocator, allocate/deallocate were header-inlined and carried the whole tracker+malloc+onAlloc/onFree(+EH) body, which made the vector fill-constructor too large to inline, so it became an out-of-line call. doCompressData then makes 4 out-of-line vector-ctor calls plus out-of-line predictor dtor calls; those clobber caller-saved registers and shift register allocation across the hot function. The generic-scheduled ARM target loses throughput there, x86 absorbs it. The cold helper did nothing because it lives inside that out-of-line constructor.

Fix (in the allocator, as you asked): moved the machinery into AllocatorWithMemoryTracking.cpp so allocate/deallocate inline to a single call, matching std::allocator's shape (operator new/delete are also out-of-line). The fill-constructor inlines back into doCompressData and the out-of-line ctor calls disappear. Tracking is unchanged. Pushed as c7c967c; the arm/2 Performance Comparison job is the measurement of record.

@Algunenano

Copy link
Copy Markdown
Member

@groeneai Could you please use the project's NO_INLINE if possible, instead of gnu::noinline?

Also, I think the changes might be positive in general so let's wait for CI, but another option would be to make FPCOperation constructor NO_INLINE. That's what I see in my local x86 build, that is the constructor is not inlined, so it does not cause the extra register spill in doCompressData that happens in ARM.

…C codec ARM regression

PR ClickHouse#105580 converted the FPC codec predictor tables (DfcmPredictor,
FcmPredictor) from std::vector to VectorWithMemoryTracking. On ARM this
regressed the codecs_float_insert benchmark (query 12) by ~16%.

Root cause: AllocatorWithMemoryTracking::allocate()/deallocate() carried
the full tracker + malloc + onAlloc/onFree body inline. That made the
container fill-constructor too large for the inliner, so it became an
out-of-line call. doCompressData then made several out-of-line
vector-constructor calls, which perturbed register allocation across the
hot function. Generic-scheduled ARM lost throughput; x86 absorbed it.

Move the allocation machinery into AllocatorWithMemoryTracking.cpp so
allocate()/deallocate() inline to a single call, matching the shape of
std::allocator (operator new/delete are also out-of-line). The
fill-constructor inlines back into doCompressData and the out-of-line
constructor calls disappear. Memory tracking is unchanged: every
allocation still goes through CurrentMemoryTracker.

The bad_alloc throw stays in a cold, never-inlined helper (NO_INLINE)
so the inline allocate() body carries no exception-handling machinery.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the fix-fpc-codec-arm-perf-regression-106606 branch from c7c967c to 8897049 Compare June 23, 2026 11:26
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in 88970498f1c: swapped [[gnu::noinline]] for the project NO_INLINE macro on the cold throw helper (plus #include <base/defines.h>). No behavior change; rebuilt, FPC round-trip still lossless.

Kept the allocator-level fix rather than the FPCOperation constructor NO_INLINE: the allocator change makes allocate()/deallocate() inline to a single call so the fill-constructor inlines back into doCompressData, which helps every tracked container, not just this codec. The FPCOperation constructor NO_INLINE is a good narrower fallback if the arm/2 job does not confirm recovery on this commit.

@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.30% +0.00%
Functions 92.50% 92.50% +0.00%
Branches 77.50% 77.50% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 16/21 (76.19%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI fully finished on HEAD 8897049 (Finish Workflow SUCCESS). One non-success test check, not PR-caused:

  • Stress test (amd_tsan) - "Unexpected exception in refresh scheduling" (STID 2508-3e7b) - chronic trunk RefreshTask scheduling crash on shutdown, unrelated to this AllocatorWithMemoryTracking change (66 unrelated PRs / 86 hits / 15 master in 30d). Tracked separately. The "Cannot start clickhouse-server" / "Check failed" rows in the same job are downstream artifacts of that single stress crash.

No PR-caused failures on this head. The amd/arm_release Performance Comparison (arm/2 query #12, codecs_float_insert) remains the measurement of record for the regression recovery.

@Algunenano

Copy link
Copy Markdown
Member

It's hard to say if this is fully fixed, but at least the codec runs we had were on the positive side:

All changes above 1.10x, cross-referenced against 30 days of master history.

AMD (Intel Sapphire Rapids)

┌───────────┬───────────┬───────────────────────────┬─────┬──────────────────────────────┬───────────────────────────────────────────┐
│ Magnitude │ Direction │           Test            │ Q#  │     Master slower/total      │                  Verdict                  │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 6.55x     │ slower    │ file_table_function       │ 24  │ 0 slower, 10 unstable / 229  │ Unstable (flagged unstable in PR too)     │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 2.46x     │ faster    │ parallel_hash_build_phase │ 0   │ 13 slower, 145 unstable /    │ Unstable                                  │
│           │           │                           │     │ 645                          │                                           │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 1.30x     │ slower    │ split_filter              │ 0   │ 42 / 645 (6.5%)              │ Flaky                                     │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 1.27x     │ faster    │ codecs_float_select       │ 20  │ 0 / 226                      │ Noise (also chronic-slow on ARM)          │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 1.27x     │ faster    │ codecs_float_select       │ 23  │ 0 / 240                      │ Noise                                     │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 1.25x     │ slower    │ join_runtime_filter       │ 9   │ 40 / 498 (8%)                │ Flaky                                     │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 1.25x     │ slower    │ split_filter              │ 1   │ 37 / 645 (5.7%)              │ Flaky                                     │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 1.23x     │ slower    │ arithmetic                │ 26  │ 2 / 101                      │ Rarely on master (borderline, low         │
│           │           │                           │     │                              │ samples)                                  │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 1.20x     │ slower    │ index_bulk_filtering      │ 2   │ 16 slower, 28 unstable / 647 │ Flaky                                     │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 1.20x     │ faster    │ grace_hash_join           │ 1   │ 178 unstable / 645           │ Unstable                                  │
├───────────┼───────────┼───────────────────────────┼─────┼──────────────────────────────┼───────────────────────────────────────────┤
│ 1.19x     │ faster    │ re2_regex_caching         │ 5   │ 31 / 646 (chronic-slow)      │ Noise                                     │
└───────────┴───────────┴───────────────────────────┴─────┴──────────────────────────────┴───────────────────────────────────────────┘

ARM (Graviton 4)

┌───────────┬───────────┬──────────────────────────────────────┬─────┬──────────────────────────────┬────────────────────────────────┐
│ Magnitude │ Direction │                 Test                 │ Q#  │     Master slower/total      │            Verdict             │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 2.76x     │ slower    │ sort_patterns                        │ 2   │ 12 slower, 42 unstable /     │ Flaky/unstable                 │
│           │           │                                      │     │ 1139                         │                                │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.81x     │ faster    │ codecs_float_select                  │ 21  │ 141 / 396 (chronic-slow)     │ Noise (reverts chronic         │
│           │           │                                      │     │                              │ slowness)                      │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.76x     │ faster    │ codecs_float_select                  │ 20  │ 157 / 387 (chronic-slow)     │ Noise                          │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.72x     │ slower    │ codecs_int_insert                    │ 3   │ 0 slower, 25 unstable / 629  │ Unstable                       │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.62x     │ slower    │ aggregate_functions_of_group_by_keys │ 1   │ 33 slower, 47 unstable /     │ Flaky                          │
│           │           │                                      │     │ 1136                         │                                │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.57x     │ faster    │ grace_hash_join                      │ 5   │ 127 unstable / 1133          │ Unstable                       │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.39x     │ slower    │ group_by_fixed_keys                  │ 11  │ 4 slower, 87 unstable / 837  │ Unstable                       │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.36x     │ slower    │ group_by_fixed_keys                  │ 7   │ 3 slower, 66 unstable / 777  │ Unstable                       │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.32x     │ slower    │ queries_over_aggregation             │ 3   │ 15 slower, 38 unstable /     │ Flaky                          │
│           │           │                                      │     │ 1138                         │                                │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.25x     │ faster    │ prefetch_in_aggregation              │ 5   │ 12 slower, 49 unstable / 815 │ Noise                          │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.21x     │ faster    │ decimal_aggregates                   │ 18  │ 109 unstable / 472           │ Unstable                       │
├───────────┼───────────┼──────────────────────────────────────┼─────┼──────────────────────────────┼────────────────────────────────┤
│ 1.18x     │ slower    │ aggregation_in_order_2               │ 6   │ 24 / 1136 (2%)               │ Flaky                          │
└───────────┴───────────┴──────────────────────────────────────┴─────┴──────────────────────────────┴────────────────────────────────┘

Summary

- Genuine regressions never seen on master: 0 on either architecture.
- Genuine improvements: 0 confirmed. The codecs_float_select "faster" entries (#20/#23 on AMD, #20/#21 on ARM) are not real speedups: those queries are chronically slower on master (up to 40% of ARM runs), so the PR landing in the fast band is run-to-run variance, not a fix.
- Flaky / unstable / dismissed: all of the above.
- Extreme outliers (>2x):
  - file_table_function #24 AMD 6.55x slower — flagged unstable, never slower on master.
  - parallel_hash_build_phase #0 AMD 2.46x faster — heavily unstable test (145/645).
  - sort_patterns #2 ARM 2.76x slower — known flaky/unstable on master.

Verdict: clean. No regression or improvement attributable to this PR. Every change above 1.10x is explained by known flaky/unstable behavior on master. The one borderline item, arithmetic #26 AMD (1.23x slower, 2/101 on master), has too few master samples to call but is well within normal flake territory.

Let's merge it and consider #106606 closed

@Algunenano
Algunenano enabled auto-merge June 23, 2026 17:27
@Algunenano
Algunenano added this pull request to the merge queue Jun 23, 2026
Merged via the queue into ClickHouse:master with commit d2e4a2e Jun 23, 2026
165 of 167 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 23, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…perf-regression-106606

Out-of-line AllocatorWithMemoryTracking allocate/deallocate to fix FPC codec ARM regression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-performance Pull request with some performance improvements 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.

ARM performance regression: codecs_float_insert query 12 is slower

4 participants