Repository navigation
Read hashed dictionary attributes from typed columns while loading - #130965
Conversation
`HashedDictionary::blockToAttributes` read every attribute value through a virtual `IColumn::get` into a `Field`, followed by `Field::safeGet`. When the column has the attribute type, read the value directly from `ColumnVector`, `ColumnDecimal` or `ColumnString` (with the null map of `ColumnNullable`). Other columns (`Array`, `Map`, `Object`, or a source returning a different type than the attribute) still go through `Field`. Reloading a 3M-key simple-key dictionary takes 0.20 s instead of 0.34 s on Neoverse V2, for both `HASHED` and `SPARSE_HASHED`. This also recovers the `hashed_dictionary_sharded` and `hashed_dictionary_load_factor` regressions of `-mbranch-protection=pac-ret` on ARM, which come from signing these per-row calls in a loop bound by cache misses. Related: #119685 Related: #119685 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [2030fbe] Summary: ✅
AI ReviewSummaryPR #130965, reviewed at Final Verdict✅ Approve. |
…efault database A `QUERY` dictionary source runs in the default database of the session, so `SELECT * FROM src_05621` failed with `UNKNOWN_TABLE` when the test ran in its own database, as in the Fast test. Use `TABLE` sources, which take the current database, and read the ordered rows through a view. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130965&sha=7207c2e2e59e75fd6ab12fe2f37dc11f3e3786ba&name_0=PR&name_1=Fast%20test #130965 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/Dictionaries/CMakeFiles/clickhouse_dictionaries.dir/HashedDictionary.cpp.o |
19.79 MiB | 20.56 MiB | +795.55 KiB (+3.93%) |
src/Dictionaries/CMakeFiles/clickhouse_dictionaries.dir/SparseHashedDictionary.cpp.o |
21.11 MiB | 21.78 MiB | +683.10 KiB (+3.16%) |
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Slowest function optimization changes (ThinLTO)
Median per-function time ratio to the master baseline: programs/clickhouse ×0.68, programs/clickhouse-keeper ×0.66 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.
| Binary | Function | Master | PR | Δ vs median |
|---|---|---|---|---|
programs/clickhouse |
DB::registerFunctionConversion(DB::FunctionFactory&) |
5.8 s | 14.2 s | +10.3 s (+261%) |
programs/clickhouse |
_ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… |
3.3 s | 7.4 s | +5.2 s (+228%) |
Compile time of recompiled translation units
9 translation units recompiled, 81 s compile time in total, 9 of them have a recent master baseline.
Symbol sizes
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse |
_ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… |
86.68 KiB | 164.38 KiB | +77.69 KiB (+89.63%) |
HashedDictionary::blockToAttributesreads every attribute value through a virtualIColumn::getinto aField, followed byField::safeGet. When the source column has the attribute type, this change reads the value directly fromColumnVector,ColumnDecimalorColumnString, using the null map ofColumnNullablefor nullable attributes. Other columns still go throughField:Array,Map,Object, and a source that returns a different type than the attribute (e.g.UInt16for aUInt64attribute).Median reload time of a 3M-key simple-key dictionary on Neoverse V2, alternating binaries:
SPARSE_HASHEDHASHEDf9e6c60epac-ret)pac-ret, before this changepac-ret, this changeThis recovers the
hashed_dictionary_sharded #3andhashed_dictionary_load_factor #3regressions that #119685 shows on ARM. They come from signing these per-row calls in a loop bound by cache misses; the analysis is in #119685 (comment).The new test compares every kind of attribute with the source table. It covers numbers,
UInt256,Decimal,DateTime64,UUID,IPv4,IPv6,String,Nullablewith NULLs,Array(theFieldpath), duplicate keys,HASHED,SPARSE_HASHED, shards, and complex keys. Its reference was produced with the master binary.Related: #119685
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Faster loading of
HASHEDandSPARSE_HASHEDdictionaries: attribute values are read directly from the source columns instead of through a generic value per row.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/130965]
Version info
26.11.1.2140-master(included in26.11and later)