Repository navigation
Conversation
|
Workflow [PR], commit [13978c0] Summary: ❌
AI ReviewSummaryThis PR switches Findings
Tests
Final Verdict
|
| else | ||
| { | ||
| for (size_t i = 0, j = 0; i < size; i += a_n, ++j) | ||
| c[j] = Op::apply(memcmpSmallMultipleOf16(a_data.data() + i, b_data.data() + i, a_n), 0); |
There was a problem hiding this comment.
This PR is filed as a Performance Improvement, but there is still no evidence that the new multiple-of-16 branch is a net win on the FixedString(32) / FixedString(48) / FixedString(64) workloads it touches here. The generic Performance Comparison shards are still PENDING, and there is no focused benchmark in the PR description, so the claimed speedup is currently unproven. Please attach before/after numbers (or a small benchmark) for the exact compare paths changed here before we merge under a performance-improvement contract.
Address review: the previous perf test built its `FixedString(32/64/128)` values with `toFixedString(reinterpretAsFixedString(number), N)`, which only fills 8 live bytes and zero-pads the rest. Both operands therefore differed within the first 8 bytes, so `memcmpSmallMultipleOf16` returned after its first 16-byte block and the multi-block path this PR optimizes was never exercised. Rewrite the test to store the values in `MergeTree` tables (so the heavy string construction happens once in the fill query and the measured queries are dominated by the comparison), give every value a long shared `_` prefix and keep the varying part in the last 16-byte block, and add equal-string and `ORDER BY` queries. This exercises both changed surfaces: `StringComparisonImpl` (`<` / `>`) and `ColumnFixedString::compareAt` (sorting). `=` / `!=` are left out on purpose because they use `memequalSmallAllowOverflow15`, which this PR does not change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address review (ClickHouse#109381): `StringComparisonImpl` routes both its column-vs-column branch and its column-vs-constant branch (`WHERE a < '...'`, the `a_n == b_size` case in `FunctionsComparison.h`) through `memcmpSmallMultipleOf16` for `FixedString(x*16)`, but the perf test previously exercised only the column-vs-column path and `ORDER BY`. Add `<` / `>` queries comparing each column against a `FixedString(N)` constant that shares the same `_` prefix, so the comparison scans every 16-byte block before the difference in the last one. Verified with `EXPLAIN actions` that `less` receives a `FixedString(N)` column and a `Const(FixedString(N))` (the `vector_constant` branch this PR changes) and that every query runs in `clickhouse-local`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The `n == 16 -> memcmp16` fast path added to `ColumnFixedString::compare` is only reachable through `compareAt` and the sort comparator, i.e. the `ORDER BY` surface. The `<` / `>` queries do not exercise it: for `FixedString(16)` `StringComparisonImpl` dispatches to `memcmpSmallMultipleOf16` directly rather than through `ColumnFixedString::compare`. The `ORDER BY` block previously started at `FixedString(32)`, so this branch was left unmeasured. Add `SELECT a FROM fixstr_cmp_16 ORDER BY a FORMAT Null` so the `n == 16 -> memcmp16` branch of `compare` is benchmarked, as requested in the review. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 20/42 (47.62%) · Uncovered code |
|
I've checked it locally for sizes 32 and 128. There's no difference at all. |
A PR to check if it would be faster to compare FixedStrings(x*16) with
memcmpSmallMultipleOf16Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
slightly faster FixedString(x*16) compare