Repository navigation
Fill values_index in ColumnSparse::indexImpl by scattering offsets - #128852
Conversation
…s instead of walking the iterator `sparse_column_index_runs` is 18-21% slower with `clang-23`, all of it in `ColumnSparse::index`. The loop that materializes a value index for every row compared each row with the next offset through `Iterator::getValueIndex`; `clang-22` compiled that into a well-predicted branch (most rows are defaults), `clang-23` if-converts it into `cmovne`/`sete`, which puts the load of `offsets[current_offset]` on a loop-carried dependency chain and serializes the loop at the load latency. Zero-fill the array and scatter `i + 1` at each offset instead. That is O(size + offsets), touches every offset once and has no per-row branch or `cmov` at all, so neither compiler can pessimize it. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=4a12a96fba025fb6340160f135a68025f4da2464&name_0=PR&name_1=Performance%20Comparison%20%28amd_release%2C%20master_head%2C%202%2F6%29 Related: #117346 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [b56d81d] Summary: ✅
AI ReviewSummaryReplaces the row-by-row lookup construction in Tests
Final VerdictStatus: |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 6 s compile time in total, 7 of them have a recent master baseline. |
The loop that materializes a value index for every row compared each row with the next offset through
Iterator::getValueIndex. clang 22 compiles that into a well-predicted branch; clang 23 if-converts it intocmov, which puts the load of the offsets on a loop-carried dependency chain (sparse_column_index_runs18-21% slower in #117346). Zero-fill the array and scatteri + 1at each offset instead: O(size + offsets), every offset touched once, no per-row branch orcmovat all, so neither compiler can pessimize it.Related: #117346
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Slightly faster
indexof sparse columns.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/128852]
Version info
26.11.1.1748-master(included in26.11and later)