Repository navigation
Resolve JSON path presence and Dynamic variant serializations once per block in JSONAllPaths and JSONAllValues - #122387
Conversation
…r block JSONAllPaths and JSONDynamicPaths looked every typed and dynamic path up by name in the ColumnObject path maps and called a virtual isNullAt on it, for every row: with 202 dynamic paths that is 202 string-hash probes per row even when the row holds 12 paths. JSONAllValues made the same checks and wrote each dynamic-path value through SerializationDynamic::serializeText, which resolves the serialization of the variant by type name through DataTypesCache for every value. A text index over JSONAllPaths(json) or JSONAllValues(json) pays both on every inserted block. Resolve, once per block, the local discriminators of each dynamic path and, for JSONAllValues, the serialization of each variant, with the same DataTypesCache getSerialization(name, type) call serializeTextImpl makes per value. A row is NULL exactly when its local discriminator is NULL_DISCRIMINATOR, which is what ColumnDynamic::isNullAt checks. A value whose serialization is exactly SerializationString (a String variant) is copied as is, because SerializationString::serializeText writes the raw bytes. The shared variant is left unresolved and keeps going through SerializationDynamic::serializeText: its storage column is a ColumnString of type-tagged binary values that must be decoded one by one. Typed and dynamic paths are disjoint, so the dynamic-first lookup of shouldIncludePath was never needed, and the helper is removed. JSONAllPathsWithTypes and JSONDynamicPathsWithTypes keep their per-row lookups, to keep this change small; JSONAllPathsWithTypes measured unchanged. Measured on x86_64 (-O3 builds of one commit without ThinLTO, servers on disjoint pinned 8-core sets, 1M rows, 8 alternating pairs, both side orders, A/A control): INSERT with a JSONAllPaths text index -26% / -30%, with a JSONAllValues index -15% / -18% (sparse) and -6% / -11% (dense), INSERT from String with a JSONAllPaths index -28% / -29%, and JSONAllValues over dense JSON -84% / -85%. INSERT without an index and JSONAllPathsWithTypes show no change that holds in both side orders, and 1024-row blocks are faster too. The output of all seven functions and every file of the indexed parts are byte-identical before and after. Closes ClickHouse#122226 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the two property comments on the cached discriminators and serializations to one line each, drop the comment restating what PathNullCheck::typed does, and put the existing NULL-skip comment back where it was. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 findings in round 1, 0 in the round-2 recheck) plus my own cold review of each round (5 findings listed here).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-48:20260926-044503 |
|
Workflow [PR], commit [45f860d] Summary: ❌
AI ReviewSummaryPR #122387 resolves path presence and Missing context / blind spots
Final VerdictStatus: ✅ Approve |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
perf.py expands every {name} in a setup or measured query as a substitution
placeholder, so the JSON object literals in both fill queries made it abort the
test before any query ran ("Failed to substitute parameters (KeyError ...)" in
the Performance Comparison report). Double the braces: perf.py renders them
back to single braces, so the executed SQL is unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes4 object files changed (+75.81 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units8 translation units recompiled, 15 s compile time in total, 8 of them have a recent master baseline. |
CI finish ledger - 9e7bcacEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 169 check runs completed (148 pass, 19 not selected, 2 red), Session id: cron:our-pr-ci-monitor:20260926-203259 |
|
|
…and-serializations-per-block Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master now enables clang-tidy `modernize-use-nodiscard`, which flags this const member function added by this PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Iceberg configuration of the performance comparison rewrites the test's MergeTree tables to Iceberg, and a `JSON` column has no Iceberg equivalent, so all six `Performance Comparison (arm_release, master_head, iceberg_*)` jobs failed with `Column data of type JSON has no Iceberg equivalent`. The test measures functions over the `JSON` type, not the storage, so opt it out with `<test iceberg="0">` rather than the skip list (changing the skip list would run the whole Iceberg configuration in this pull request). https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122387&sha=067b87fd8ae813d7fdd4592cb810603d156370e3&name_0=PR Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 45f860dEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261116-200022 |
|
Fixing PR for In that run the consumer's connection outlived the broker restart as a dead socket: no PONG came back, and the client's ping timer declared it stale 240 s after it had connected. After that, each of the 43 reconnects was torn down by the client within 0.43 ms, with nothing logged by the broker, so the table did not resume before the test gave up. The broker had restored all 100000 messages. The vendored client does not reset its protocol parser on a disconnect when an event loop is attached (nats-io/nats.c#1007), and a parse error leaves the parser state as it is, so a connection cut mid-message fails again on every new socket. The reset is ClickHouse/nats.c#9: master's |
Closes: #122226
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Speed up
INSERTinto a table with a text index overJSONAllPaths(json)orJSONAllValues(json), and the functionsJSONAllPathsandJSONAllValuesthemselves, by resolving each path's presence and each value's serialization once per block instead of once per row.Description
For every row,
JSONAllPathsandJSONDynamicPathslooked each path up by name and called a virtualisNullAt;JSONAllValuesmade the sameisNullAtcall and resolved each dynamic value's serialization by type name throughDataTypesCache. A text index over them pays this on every inserted block.Now each dynamic path's local discriminators and each variant's serialization are resolved once per block. The NULL test is the discriminator comparison
ColumnDynamic::isNullAtmakes; a dynamic value whose serialization is exactlySerializationStringis copied as is, as itsserializeTextdoes. Other values keep going throughserializeText, the shared variant through theDynamicone. No setting, serialization or format changes.x86_64,
-O3builds of the base and the patched tree with identical flags (no ThinLTO), servers on disjoint pinned 8-core sets, 1M rows, 8 alternating pairs ofquery_duration_ms:INSERT, sparse,JSONAllPathsindexINSERT, sparse,JSONAllValuesindexINSERT, dense,JSONAllValuesindexJSONAllValues, denseJSONAllValues, sparse, 1024-row blocksINSERT, no index (control)The output of all seven
JSON*Paths*/JSONAllValuesfunctions and every file of the indexed parts is byte-identical before and after.JSONAllPathsWithTypesandJSONDynamicPathsWithTypeskeep their per-row lookups, to keep this change small.#120403 replaces the
getSerialization(name, type)overload used here and cheapens that lookup, as #113344 does for binary serialization.The performance test is the first for these functions.
All statements
INSERT, sparse,JSONAllPathsindexINSERT, sparse,JSONAllValuesindexINSERT, dense,JSONAllPathsindexINSERT, dense,JSONAllValuesindexINSERT, sparse fromString,JSONAllPathsindexINSERT, sparse, no indexINSERT, dense, no indexJSONAllPaths, sparseJSONAllValues, sparseJSONAllValues, denseINSERT,JSONAllPathsindex, 1024-row blocksJSONAllValues, sparse, 1024-row blocksJSONAllPathsWithTypes, sparseWorkflow [PR]
Sync PR [sync-upstream/pr/122387]