Skip to content

Fix quadratic reallocation while building h3 array results - #115773

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-quadratic-realloc-h3-array-building
Aug 21, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-quadratic-realloc-h3-array-building

Conversation

@groeneai

@groeneai groeneai commented Aug 21, 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):

Fixed quadratic time when the functions h3kRing, h3ToChildren, h3PolygonToCells and h3PolygonToCellsWithContainment build their result over many rows. A query over 196 000 rows spent 838 seconds copying memory in a CI stress run; it now takes about 5 seconds.

Description

Related: #112897 (same defect class, merged)

A Stress test (amd_asan_ubsan) hung check aborted with one query at elapsed = 838 s against its
own max_execution_time = 10, having written 0 rows. Its stacktraces shows the working thread in
__memmove_sse2_unaligned_erms under asan_realloc under FunctionH3KRing::executeImpl: running
flat out, not stuck. Report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114559&sha=7698f8b0d63a71a717fb84a0ffb58a701e12223a&name_0=PR&name_1=Stress%20test%20%28amd_asan_ubsan%29

These four functions reserve the result accumulator once per row, e.g.
dst_data.reserve(dst_data.size() + vec_size) at h3kRing.cpp:132. dst_data is a
ColumnUInt64 & and ColumnVector::reserve is reserve_exact, so capacity lands exactly on the
current size every row and the next row reallocs, copying the whole accumulated array: Θ(n²),
about 11.6 TB of memmove here (peak memory was only 102 MB).

Reserving through PODArray::reserve rounds capacity up to a power of two, making the copying
amortized O(n). IColumn::reserve affects performance only, and reserve_exact suits the many
callers reserving a final size once, so the four per-row callers are the bug, not the primitive.

Cancellation had already been delivered, but the existing per-action check cannot fire inside one
IFunction::executeImpl; removing the quadratic factor is what lets it run.

Validated under ASAN, where the defect shows (a Debug build is linear, because glibc realloc
extends in place; every CI occurrence is a sanitizer job). Unfixed the query does not finish in
400 s; fixed it returns the same result in 4.8 s. All four functions were measured in both
directions, results are byte-identical, and peak memory rises ~1.45x, the expected cost of geometric
growth. The new test aborts on unfixed master with TIMEOUT_EXCEEDED on its first statement and
passes in 1.3 s; the 59 existing h3 tests pass.

Two sites share the shape with a constant per-row amount, which lowers the factor without
bounding the total; each is left for its own change: s2GetNeighbors.cpp:102 (4 per row) and
AggregateFunctionCategoricalInformationValue.cpp:138 (the function's arity).


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

Version info

  • Merged into: 26.8.1.1878 (included in 26.8 and later)

h3kRing, h3ToChildren, h3PolygonToCells and h3PolygonToCellsWithContainment
reserved the result accumulator once per row:

    dst_data.reserve(dst_data.size() + vec_size);

dst_data is a ColumnUInt64 &, and ColumnVector::reserve is reserve_exact,
which reallocs to exactly the requested size. Capacity therefore landed
exactly on the current size at every row, the next row reallocated, and the
whole accumulated array was copied each time: Theta(n^2).

A Stress test (amd_asan_ubsan) hung check caught this with one query at
elapsed 838 s against its own max_execution_time = 10, having written 0
rows, with the working thread inside __memmove_sse2_unaligned_erms under
asan_realloc under FunctionH3KRing::executeImpl. That is about 11.6 TB of
memmove for the 196 227 rows involved, which matches the 838 s. Peak memory
was only 102 MB, so the query was never short of memory.

Reserving through PODArray::reserve rounds capacity up to a power of two,
so the copying is amortized O(n). IColumn::reserve is documented as
affecting performance only, and reserve_exact is the right semantics for
the many callers that reserve a final size once, so the four per-row
callers are the defect rather than the primitive.

Cancellation was already delivered on the reported query (is_cancelled = 1)
and ExpressionTransform already checks it once per action, but the whole
838 s sat inside a single IFunction::executeImpl, so no action boundary was
reached again. Removing the quadratic factor is what lets that existing
check fire.

Validated under ASAN, which is where the defect is measurable: a Debug
build is linear on the same query because glibc realloc can extend the
block in place, consistent with every occurrence in CI being a sanitizer
job. Unfixed, the reported query does not finish in 400 s; fixed it returns
the same result in 4.8 s, and unfixed scaling is a clean quadratic (2.7 /
6.2 / 21.1 / 81.7 s as rows double from 2 000 to 16 000). All four
functions were measured in both directions, and reverting only the h3kRing
line returns that arm to a timeout. Results are byte-identical before and
after, including invalid cells, mixed valid and invalid rows, Nullable,
LowCardinality and zero, one and two row inputs. Peak memory rises about
1.45x, the expected cost of geometric growth.

The new test fails on unfixed master with TIMEOUT_EXCEEDED and passes in
25 s. Its oracle is completion under a per-statement max_execution_time
rather than an elapsed-time assertion.

s2GetNeighbors.cpp has the same shape but reserves a constant 4 elements
per row, a much weaker exposure in a different area, so it is left alone.
The last arm of 04910 was introduced to show that a row producing no cells
does not shift the offsets of its neighbours, but both cells it passed were
valid, so no row was empty and the arm only repeated the earlier length()
assertions.

Pass an invalid cell index on either side of a valid one under
functions_h3_default_if_invalid, which makes h3kRing take the `continue`
branch that writes dst_offsets[row] without appending to the accumulator.
The expected 0, 7, 0 then distinguishes correct offset bookkeeping from a
shift. The setting is required: without it an invalid cell throws
INCORRECT_DATA instead of yielding an empty row, which was verified so the
arm cannot silently degrade into an exception test.
The regression test gave all four carriers a max_execution_time arm at 40 s.
Two of them cannot support a timing claim: the polygon functions spend far
more compute per output cell, so reaching a useful unfixed/fixed ratio costs
tens of seconds of fixed time on its own.

Keep the oracle on h3kRing and h3ToChildren, which reach it cheaply, and let
the two polygon arms assert values only, at sizes that run in well under a
second. Each polygon arm asserts a non-zero sum, so it still has to grow the
accumulator to pass. The whole file drops from 24.9 s to 1.3 s.

The limit is 15 s rather than 40 s because max_execution_time is only observed
at a block boundary: the unfixed arm aborts after its first 65 409-row block
at about 63 s, not at the 126 s the statement would take, and that time is flat
in the limit (measured at 5, 10 and 20 s). Redden margin is therefore 63/L,
which leaves only 1.6x at 40 s. At 15 s the fixed arms use 0.14-0.21 s, so the
margins are 73x against a flaky pass and 4.2x against failing to redden.

max_block_size stays pinned on the timing arms: the accumulator is rebuilt per
block, so the cost is linear in the block size and the runner randomizes it
between 8000 and 100000.

Reverting only the h3kRing line on the otherwise-fixed tree reddens the first
arm while the second still passes, so the two arms are independent oracles.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Aug 21, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)

Three review rounds against an independent model, plus my own cold read of the tree each round.
Two rounds bounced back for changes; every finding below is adjudicated with evidence. The four
src/ lines have been identical since the first reviewed head - all three rounds moved the test
and the claims, never the fix.

# Finding Verdict
❌ The test's four 40 s timing arms had too little headroom for instrumented builds (raised twice) AGREE - fixed. The oracle now sits on h3kRing and h3ToChildren only, at max_execution_time = 15. Choosing the limit turned up a measurement the earlier rounds did not have: max_execution_time is observed at a block boundary, so the unfixed arm aborts after its first 65 409-row block at ~63 s rather than at the 126 s statement cost, flat in the limit (measured at 5, 10 and 20 s). Redden margin is therefore 63/L, which would have left only 1.6x at 40 s. At 15 s the margins are 73x against a flaky pass and 4.2x against failing to redden. Whole file 24.9 s -> 1.3 s.
❌ The two polygon arms are not mechanism-live: reverting either polygon line changes capacity and runtime, not the returned cells, so the arms still pass DISAGREE on the remedy, AGREE on the fact - the observation is correct and the arms now say so. No deterministic allocation observable exists to give them a mechanism oracle: there is no reallocation ProfileEvent, and the one memory observable moves the wrong way (peak rises ~1.45x after the fix, so a memory arm would redden the fix and pass the base). A timing arm is affordable only on the two cheap functions - the polygon functions need ~9 s of fixed time to reach a usable ratio, which is the whole file's budget. Removing the arms would leave those two changed lines with no test at all, while they do currently fail on a correctness break. So the before/after for both polygon functions is presented as measurement (246 s -> 11.1 s, >250 s -> 21.6 s), not as regression coverage.
❌ The scope claim for "every carrier was found" was broader than the sweep behind it (raised in all three rounds, each time about the claim rather than the code) AGREE - narrowed each time. Round 1 added src/AggregateFunctions/, which surfaced AggregateFunctionCategoricalInformationValue.cpp:138; round 2 restated the test as two explicit conditions; this round found that the same test also selects MergeJoinTransform.cpp:1301, where the columns are built once and appended to inside the merge loop. All of these have a constant or out-of-subsystem shape and are disclosed rather than folded in - one root cause per PR.
⚠️ The changelog paired a CI-measured 838 s with a locally measured ~5 s AGREE - the 838 s is now attributed to the CI stress run.
⚠️ The "empty row must not shift offsets" arm contained no empty row (both cells were valid) AGREE - the arm now uses arrayJoin([0, 579205133326352383, 0]) under functions_h3_default_if_invalid = 1, giving 0, 7, 0. The setting is load-bearing: without it an invalid cell throws instead of yielding an empty row.
⚠️ Missing long tag on a 25 s file AGREE, then closed by measurement - the file now runs in 1.3 s, ~140x under the flaky-check threshold, so no tag.
💡 An earlier round's prescription assumed the quadratic term spans the statement, so cutting rows would buy base cost cheaply Withdrawn - my prescription was wrong. The accumulator is constructed inside executeImpl, so it resets per block: cost is Θ(B²) per block over n/B blocks, i.e. linear in rows and linear in block size. Holding rows fixed at 60 000 and halving max_block_size twice gave 51.99 / 26.94 / 14.05 s, which settles it. The prescribed row cuts measurably worsened the ratio (8.00x -> 3.51x on one arm), so refusing to ship them was right. max_block_size stays pinned on the timing arms for the same reason.

Both prior rounds' timing-margin concern was raised twice and is fixed rather than overridden. The
one DISAGREE concedes its factual claim and refutes only the two remedies it prescribes, each with
a measurement.

Session id: cron:clickhouse-review-slot-10:20260821-104700

@clickhouse-gh clickhouse-gh Bot closed this Aug 21, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 21, 2026
@groeneai

groeneai commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SELECT sum(length(a)) FROM (SELECT h3kRing(arrayJoin([579205133326352383]), arrayJoin([toUInt16(7), toUInt16(2), toUInt16(3)])) AS a FROM numbers(65409)) SETTINGS max_block_size = 65409 under ASAN. Not probabilistic: the cost scales as a clean quadratic, 2.7 / 6.2 / 21.1 / 81.7 s as rows double from 2 000 to 16 000.
b Root cause explained? Yes. The four functions reserve the result accumulator once per row (dst_data.reserve(dst_data.size() + vec_size), h3kRing.cpp:132). dst_data is a ColumnUInt64 &, ColumnVector::reserve is reserve_exact, and PODArray::reserve_exact reallocs to exactly the requested bytes. Capacity therefore lands exactly on the current size at every row, the next row reallocs, and the whole accumulated array is copied: Θ(n²), about 11.6 TB of memmove for the reported query, which matches the 838 s observed.
c Fix matches root cause? Yes. It changes the accumulator's growth policy at the four call sites that misuse the primitive, so copying becomes amortized O(n). No widened bound, no raised timeout, no no-random-* tag, no cancellation check bolted onto the symptom. ColumnVector::reserve itself is deliberately left alone: exact sizing is correct for the many callers that reserve a final size once.
d Test intent preserved / new tests added? Yes. Nothing existing was weakened or removed, and the 59 pre-existing h3 tests all pass (67 s). New test 04910_h3_array_building_no_quadratic_realloc was proven to abort on unfixed master before being accepted. Every run count below is measured on the shipped bytes, not carried over from an earlier shape: 50 runs green under default randomization in 101 s, per-run 1.88-2.19 s, plus a targeted run in 1.28 s. The timing oracle sits on the two arms that can carry it with margin to spare (h3kRing, h3ToChildren: 63 s unfixed vs 0.2 s fixed against a 15 s limit); the two polygon arms assert values only and carry no timing claim: they pin the returned cells for the two polygon call sites, and would not detect a performance re-regression there. No deterministic allocation observable exists to give them one (grep -inE 'M\(.*Realloc' src/Common/ProfileEvents.cpp finds none and Allocator increments no ProfileEvents), and a timing arm on either polygon function costs about 10 s of fixed time on its own to reach a usable ratio, which is the whole file's budget. Their before/after is therefore given as measurement in row (e) rather than as test coverage.
e Both directions demonstrated? Yes, per function, and per arm. Unfixed vs fixed: h3kRing 63 s abort vs 0.19 s, h3ToChildren 63 s abort vs 0.13 s, h3PolygonToCells 246 s vs 11.1 s, h3PolygonToCellsWithContainment >250 s vs 21.6 s. At test level, on the shipped file: unfixed master rc=159 TIMEOUT_EXCEEDED on the first statement with empty stdout, fixed passes in 1.28 s. Mutation arm: reverting only the h3kRing line on the otherwise-fixed tree (Build-ID 4893b6ee, distinct from the final 07fe25b2) reddens arm 1 while arm 2 still passes in 0.125 s, so the two timing arms are independent oracles rather than one shared signal.
f Fix is general across code paths? Invariant: an accumulator appended to once per row must grow geometrically, never be re-reserved to an exact size per row. Fixed at the source rather than guarded at the failure site. Scope swept: the h3 array-building family (h3*.cpp, s2*.cpp) exhaustively, and the remaining 106 grep -rnE '\.reserve\([a-zA-Z_]+\.size\(\) *\+' src/ hits by receiver type. A site is a carrier only if it both reaches reserve_exact (an IColumn &, not an already-geometric PODArray) and sits in a per-row loop accumulating into the same column; the four h3 functions are the sites meeting both, and all four are fixed. Two same-shape per-row sites have a constant delta. That lowers the factor but does not bound the total, which stays quadratic; each is a separate area (one root cause per PR): s2GetNeighbors.cpp:102 (+4, measured on this binary at 6.30 / 22.50 / 84.30 s for 25k / 50k / 100k rows in one block, against 1.07 / 1.26 / 0.96 s with getData().reserve; raised by the reviewer bot and being fixed separately) and AggregateFunctionCategoricalInformationValue.cpp:138 (+category_count, the function's arity). IDataType.cpp:324 reaches reserve_exact through an IColumn &; three of its four call sites (RollupTransform.cpp:69, MergeJoinTransform.cpp:1356, JoinUtils.cpp:562) are one-shot bulk reserves on a freshly cloned or pre-reserved column, where exact sizing is the correct semantics. MergeJoinTransform.cpp:1301 does append repeatedly into columns built once at :1185, so it meets both conditions; it is a separate subsystem and is left for its own change rather than folded in here.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes, and verified byte-identical before and after: k=0, an invalid cell returning [] under functions_h3_default_if_invalid, mixed valid/invalid rows (0,7,0, confirming the skip path does not shift neighbouring offsets), 0/1/2-row inputs, Nullable, LowCardinality, h3ToChildren at the same resolution, a polygon covering no cells, and the PARAMETER_OUT_OF_BOUND path at k=20000.
h Backward compatible? (maintainer-approved exception only) Yes. No setting added or changed, so no SettingsChangesHistory.cpp entry is due; no format, serialization or API change. IColumn::reserve affects performance only, so results are unchanged, as the value-identity runs above show.
i Invariants and contracts preserved? Yes. reserve only raises capacity and leaves size() untouched, so the dst_offsets[row] = current_offset bookkeeping is unaffected. PODArray::reserve and reserve_exact differ only in rounding and go through the same realloc. On any throw the columns are destroyed as before; larger capacity cannot change exception behaviour beyond reducing allocation count. All four sites are single-threaded within one executeImpl, so no lock or concurrency contract is involved. Peak memory rises about 1.45x (~9 MB to ~13 MB, measured by bisecting max_memory_usage), within the 2x that geometric growth implies.

Session id: cron:clickhouse-impl-slot-5:20260821-095200

@clickhouse-gh

clickhouse-gh Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b86bdb0]

Summary: ✅


AI Review

Summary

This PR switches the four touched H3 array builders from exact ColumnVector::reserve growth to geometric PODArray::reserve, which fixes the quadratic copy behavior in the changed code paths. The H3 fix itself looks correct, but I would not clear the review as written because the current rationale for leaving s2GetNeighbors untouched is still unsound.

Missing context / blind spots
  • ⚠️ The only Praktika report visible at review time was Build profile diff, so I could not confirm that the new 04910_h3_array_building_no_quadratic_realloc stateless test has already gone green in CI.
Findings

⚠️ Majors

  • [dismissed by author -- https://github.com/Fix quadratic reallocation while building h3 array results #115773#discussion_r3830286342] [src/Functions/s2GetNeighbors.cpp:102] dst_data.reserve(dst_data.size() + 4) still exact-sizes the ColumnUInt64 accumulator on every row, so large scans keep reallocating and copying O(rows^2) data exactly like the H3 builders did before this PR. With the same 65409-row block size used to reason about the H3 timeout, this sibling still copies about 63.8 GiB of neighbor ids per block before doing the S2 work, so the current "+4 is bounded" justification is not correct. Suggested fix: switch this caller to dst_data.getData().reserve(dst_data.size() + 4), or at minimum narrow the PR rationale so it stops treating this sibling as safe to leave behind.
Final Verdict

Changes requested: the H3 fix looks good, but the already-open s2GetNeighbors sibling issue still holds in the current tree.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 87.10% 87.10% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 79.40% 79.40% +0.00%

Changed lines: Changed C/C++ lines covered: 16/20 (80.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Aug 21, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @nikitamikhaylov @scanhex12, could you review this? The four h3 array-building functions call dst_data.reserve(dst_data.size() + vec_size) once per row on a ColumnUInt64, and ColumnVector::reserve is reserve_exact, so capacity lands exactly on the current size every row and the next row copies the whole accumulated array; going through PODArray::reserve instead makes it amortized linear.

@PedroTadim

Copy link
Copy Markdown
Member

cc @alexey-milovidov

Comment thread src/Functions/h3kRing.cpp

dst_data.reserve(dst_data.size() + vec_size);
/// Go through PODArray::reserve: it grows capacity geometrically, IColumn::reserve sizes it exactly.
dst_data.getData().reserve(dst_data.size() + vec_size);

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.

The new invariant here is that one-row-per-input array accumulators must not go through ColumnVector::reserve, because exact sizing turns repeated appends into quadratic copying. src/Functions/s2GetNeighbors.cpp:102 still does dst_data.reserve(dst_data.size() + 4), and a constant +4 does not make that pattern bounded: after n rows it still copies 4 * (1 + ... + (n - 1)) = O(n^2) elements. I think this PR should either apply the same dst_data.getData().reserve(...) fix there as part of the same defect-class sweep, or narrow the scope/evidence so it no longer treats that sibling as safe to leave behind.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are right, and I have corrected the PR: the claim that a constant per-row delta made
s2GetNeighbors bounded was wrong. A constant +4 lowers the factor, not the complexity, since
ColumnVector::reserve is reserve_exact and the accumulator is reallocated on every row either
way.

I measured it rather than leave it as arithmetic, ASAN, one block, max_threads = 1:

SELECT sum(length(s2GetNeighbors(geoToS2(number * 0.0000001, 40.0)))) FROM numbers(N)
SETTINGS max_block_size = N, max_threads = 1
N current with getData().reserve
25 000 6.30 s 1.07 s
50 000 22.50 s 1.26 s
100 000 84.30 s 0.96 s

Doubling the row count multiplies the current cost by about 3.6x, so it is quadratic as you say;
the patched arm is flat and returns identical values. geoToS2 alone is flat at ~1 s, so the
quadratic term is entirely in s2GetNeighbors. One caveat for anyone reproducing this: with a
literal cell id the argument is constant-folded and the cost is flat, which looks like a refutation.

I am not folding the fix into this PR. It is a different function and area, the PR is already
reviewed and approved at this head, and a push here would restart several hours of CI for a change
that is better judged on its own. I have taken the false wording out of the description instead, and
I am opening a separate change for s2GetNeighbors with the measurement above.

Comment thread src/Functions/h3kRing.cpp

dst_data.reserve(dst_data.size() + vec_size);
/// Go through PODArray::reserve: it grows capacity geometrically, IColumn::reserve sizes it exactly.
dst_data.getData().reserve(dst_data.size() + vec_size);

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.

dst_data.getData().reserve is the right fix for these H3 builders, but the same exact-reserve-per-row pattern is still left in src/Functions/s2GetNeighbors.cpp:102:

dst_data.reserve(dst_data.size() + 4);

That still goes through ColumnVector::reserve, so capacity is exact-sized on every row and the accumulator remains O(rows^2) copies. With the same 65409-row block size used to reproduce this PR, that path still copies about 64 GiB per block before the S2 work itself. If the invariant here is "row-wise array builders must grow geometrically", this sibling needs the same getData().reserve change or a proof that it cannot hit large scans.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are right, and I have corrected the PR: the claim that a constant per-row delta made
s2GetNeighbors bounded was wrong. A constant +4 lowers the factor, not the complexity, since
ColumnVector::reserve is reserve_exact and the accumulator is reallocated on every row either
way.

I measured it rather than leave it as arithmetic, ASAN, one block, max_threads = 1:

SELECT sum(length(s2GetNeighbors(geoToS2(number * 0.0000001, 40.0)))) FROM numbers(N)
SETTINGS max_block_size = N, max_threads = 1
N current with getData().reserve
25 000 6.30 s 1.07 s
50 000 22.50 s 1.26 s
100 000 84.30 s 0.96 s

Doubling the row count multiplies the current cost by about 3.6x, so it is quadratic as you say;
the patched arm is flat and returns identical values. geoToS2 alone is flat at ~1 s, so the
quadratic term is entirely in s2GetNeighbors. One caveat for anyone reproducing this: with a
literal cell id the argument is constant-folded and the cost is flat, which looks like a refutation.

I am not folding the fix into this PR. It is a different function and area, the PR is already
reviewed and approved at this head, and a push here would restart several hours of CI for a change
that is better judged on its own. I have taken the false wording out of the description instead, and
I am opening a separate change for s2GetNeighbors with the measurement above.

@nikitamikhaylov nikitamikhaylov self-assigned this Aug 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

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

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 704.42 MiB 701.39 MiB -3.02 MiB (-0.43%)

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.

Compile time of recompiled translation units

10 translation units recompiled, 25 s compile time in total, 10 of them have a recent master baseline.

Job report

@clickhouse-gh

clickhouse-gh Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

⚠️ AI verdict: not_sure — no significant changes across 35 queries analysed

This PR only changes the H3 geospatial functions (h3kRing, h3ToChildren, h3PolygonToCells and the containment variant) to route array growth through geometric PODArray reserve, plus a new regression test. None of that code runs in the TPCH workload, so the two flagged queries (Q7 +17.9%, Q17 +59.4%) cannot be caused by this change. Both were already marked not_sure on an unstable baseline, and Q17's underlying measurements were very noisy; treat both as baseline variance, not a real shift. No perf-relevant impact expected on the benchmarked queries.

clickbench

🟢 No significant changes

tpch_adapted_1_official

⚠️ 2 inconclusive

Flagged queries (2 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 7 not_sure 67 79 +17.9% <0.0001 This PR only touches H3 geo functions (h3kRing, h3ToChildren, h3PolygonToCells), which this TPCH query never calls; the +17.9% sits on an unstable baseline and reads as variance.
⚠️ 17 not_sure 64 102 +59.4% <0.0001 Same off-path change; Q17's measurements were very noisy and its baseline is unstable, so the +59.4% is not a plausible effect of an H3-only diff.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 82bfe7d0-33c2-426c-9630-01c47944d943
  • MIRAI run: 53e4f38d-06f4-4389-a9f9-ede380f06aae
  • PR check IDs:
    • clickbench_447442_1787327637
    • clickbench_447448_1787327637
    • clickbench_447459_1787327636
    • tpch_adapted_1_official_447470_1787327636
    • tpch_adapted_1_official_447480_1787327638
    • tpch_adapted_1_official_447513_1787327637

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 21, 2026
Merged via the queue into ClickHouse:master with commit c62aa4f Aug 21, 2026
529 of 532 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 21, 2026
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 groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding 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.

5 participants