Repository navigation
Do not invalidate dictionary if there is only one of them [again] - #103662
Conversation
|
Workflow [PR], commit [c94b5be] Summary: ❌
AI ReviewSummaryThis PR improves Final Verdict
|
|
I did validate that the test fails on #99285 but not prior to that: The dictionary size is 8192, so the math checks out for the bug (we look at the first dict instead of the second): I'm fairly confident in the fix, but I haven't validated it yet as my potato x86_64 system is still doing a full rebuild: |
|
I'm curious, where can I read more about when having a single dictionary is better than having many? What's a good rule of thumb? |
|
@EmeraldShift, there's a chain of links: #99285 -> #99236 -> #98968. |
|
The new test succeeded, but the old amplification test timed out on a bunch of sanitizer builds. This was not the case in #99285. I'm not sure what happened there. It doesn't stand out all that much in regular tests:
Locally: |
47aa23e to
f70115b
Compare
f70115b to
a6c4ce0
Compare
This reverts commit 49b0c95. The fix for the discovered issue with non-adaptive parts is in the next commit.
Previously non-adaptive parts could've fooled the heuristic for single dictionary detection, now they can't and there is a test to prove it.
…mplification This makes the test faster, which matters on sanitizer targets that were too slow before.
04b0b0a to
b7aa1c3
Compare
|
I switched from Hopefully it will go away after the rebase. |
|
@Avogar, could you have a look? Thanks! |
|
Sure, I will take a look next week. Sorry for the delay, just came back from vacation recently |
…o-single-dict-reload-fixed
LLVM Coverage Report
Changed lines: 98.25% (56/57) | lost baseline coverage: 5 line(s) · Uncovered code |
|
Let's keep an eye on test |
cd05938
|
Did it fail again? List of failures, the latest one. #105375 is where it failed. Not sure if that's related to the changes in that PR. |
|
The branch in #105375 is from 2 days ago, so it doesn't include this PR. |
|
It's suspicious... But let's wait for a few more days |
|
Let's revert. I'll see if I can figure out what's missing here. |
…reload-fixed Do not invalidate dictionary if there is only one of them [again]
The precomputed distinct-mark count makes the single-dictionary check O(1), but nothing observed that the fast path was reached. Deleting it left every test green: the boolean is bit-identical, so the existing SQL tests cannot tell the memoized answer from the scanned one, and the gtest exercises MarksInCompressedFile without going through the reader. A later change to num_columns_in_mark or marks_count bookkeeping could therefore silently falsify the guard, restore the whole-part scan, and pass CI. This code path has already been reverted twice, so that is not a hypothetical cost. Count the fast path with a ProfileEvent and assert a non-zero delta from a Wide one-column LowCardinality read. Verified by deleting the fast-path block: the new test fails (1 vs 0) while 04143, 04201, 04144, 04614, 04141, 04142 and the gtest all stay green. That asymmetry is the point, since 04143 can only see the optimization stop firing, not the memoization. The event is named for the mechanism rather than for LowCardinality because SerializationObject consumes the same callback for JSON subcolumns. Also run the two version-only-DictionaryKeys tests ClickHouse#103662 added alongside 04143, and drop a dead array copy in the gtest (create takes a const ref).
…subcolumn `SerializationLowCardinality::deserializeBinaryBulkStatePrefix` asks the Wide reader's `has_uniform_marks_callback` whether the part may have a single dictionary. The callback looked the stream up with `streams.find()` and answered `false` when the reader had not opened it yet. Map bucket and Dynamic variant streams are opened lazily by the prefix getter, which runs after the callback, so the answer depended on which column sharing the stream was deserialized first: `m.keys` was treated as multi-dictionary, `m` as single dictionary, and `m`'s prefix read the shared dictionary stream to EOF. Mutations read without seeking to marks, so the data read of `m.keys` then called `read_dictionary()` on the EOF stream and failed with `CANNOT_READ_ALL_DATA` on every attempt. Open the stream in the callback, as the neighbouring callbacks already do. Regression from ClickHouse#103662 (first released in 26.6). Co-Authored-By: Claude Opus 5.5 <[email protected]>

This is #99285 plus an extra commit that fixes non-adaptive parts.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Faster discontinuous queries for
LowCardinalitycolumns with a single dictionary.Documentation entry for user-facing changes