Repository navigation
Keep the UTF-8 comparison iterators uninitialized under -ftrivial-auto-var-init - #3
Open
groeneai wants to merge 1 commit into
Conversation
…o-var-init ClickHouse builds with -ftrivial-auto-var-init=zero and compares strings with ucol_strcollUTF8(). With the flag, every comparison that leaves the Latin fast path zero-fills its two collation iterators first: 400 bytes each for UTF8CollationIterator, 496 for FCDUTF8CollationIterator, mostly the inline CE buffer. ORDER BY ... COLLATE on Cyrillic text was +15% on aarch64 in the ClickHouse performance test collations, and 10% slower than without these memsets on x86-64 (ClickHouse/ClickHouse#127909). The constructors set all iterator state that is read before it is written, and the CE buffer is only read below its length, so mark these four iterators in the UTF-8 doCompare() with `__attribute__((uninitialized))` (empty where unsupported). The identical-level NFD iterators are left as they are. Builds without the flag are not affected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai
added a commit
to groeneai/ClickHouse
that referenced
this pull request
Oct 28, 2026
…init=zero` The remaining arm_release slowdowns on this PR come from contrib code: `codecs_float_select` ClickHouse#11 (+24%) and `ip_trie` ClickHouse#2 (+18%) decode `ZSTD`, and `collations` ClickHouse#1 (+16%) compares strings with ICU. - contrib/zstd -> ClickHouse/zstd#6 (0c4a7b5): `seqState`, the `sequences` ring and the decoded `seq_t` temporaries of the sequence decoders. `ZSTD_decompressSequences`, `...SplitLitBuffer` and `...Long` then compile to the same code as without the flag on aarch64 and x86-64. - contrib/icu -> ClickHouse/icu#3 (e16b61b): the two collation iterators of the UTF-8 `RuleBasedCollator::doCompare`, 400 or 496 bytes each, zero-filled on every comparison that leaves the Latin fast path. Local amd64 release builds, flag only vs with these annotations (max_threads=1, 3 x 7 runs): ORDER BY ... COLLATE 'tr' on 2M Cyrillic strings 0.131 s -> 0.113-0.119 s; the ZSTD Float64 scan returns to 0.183 s, as without the flag (0.164 s with it). Query results are identical (8 collations, zstd levels 3 and 19 with a 128 MiB window, a ZSTD MergeTree column). Co-Authored-By: Claude Opus 5.5 <[email protected]>
motsc
previously approved these changes
Oct 29, 2026
motsc
dismissed
their stale review
October 29, 2026 15:02
AI-generated approval submitted from @motsc without explicit per-PR authorization or disclosure; withdrawn so an independent maintainer can review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ClickHouse builds with
-ftrivial-auto-var-init=zeroin ClickHouse/ClickHouse#127909 and compares strings withucol_strcollUTF8(). With the flag, every comparison that leaves the Latin fast path first zero-fills its two collation iterators (400 bytes each forUTF8CollationIterator, 496 forFCDUTF8CollationIterator, mostly the inline CE buffer).ORDER BY ... COLLATEon Cyrillic text is +16% in thecollationsperformance test onarm_release.The constructors set all iterator state that is read before it is written, and the CE buffer is only read below its length, so this marks the four iterators of the UTF-8
RuleBasedCollator::doCompare()with__attribute__((uninitialized))(empty where unsupported). The identical-level NFD iterators are left as they are. Builds without the flag are unchanged.On a local amd64 release build,
ORDER BY Title DESC COLLATE 'tr' LIMIT 1000, 10over 2M Cyrillic strings goes from 0.131 s to 0.113-0.119 s, and sorted output is identical for 8 collations (includingen-u-kk-trueandsv-u-ks-identic). ClickHouse/ClickHouse#127909 pins this commit so that its Performance Comparison measures it on both architectures.