Repository navigation
Reuse cached JSON subcolumn serializations - #110957
alexey-milovidov merged 33 commits into
Conversation
# Conflicts: # src/Storages/MergeTree/IMergeTreeDataPart.cpp
|
Workflow [PR], commit [0190e68] Summary: ✅
AI ReviewSummaryThis PR reuses safe cached Missing context / blind spots
Final Verdict✅ No new review findings at the current LLVM Coverage ReportMeasured on commit 0190e68.
Changed lines: Changed C/C++ lines covered: 80/80 (100.00%) · Uncovered code |
Build profile diff (arm_release)Commit See the job log for details. |
|
📊 Cloud Performance Report
Release-transition baseline: compared against the most recent available 26.9 masters at or before the trusted base-commit anchor because no 26.10 master baseline exists there. This PR changes how MergeTree picks and caches serializations for JSON/Object subcolumns, mostly for compact parts without substream marks. No ClickBench or TPC-H column goes through that path. The four flagged ClickBench improvements (Q18 -14.8%, Q31 -12.9%, Q32 -45.3%, Q34 -5.9%) are all GROUP BY-heavy queries with lower CPU, which points to the gap between the 26.9 master base and the newer source build rather than this diff. Q18, Q31 and Q34 are downgraded to not sure. Q32 stays an improvement only because the hard override locks it, and it should not be credited to this PR. clickbench🟢 1 improved · Flagged queries (4 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
Route the full parent lookup through the part serialization cache for every `JSON` subcolumn. Related: ClickHouse#110957
Measure declared typed-path reads from many wide parts so serialization setup remains visible. Related: ClickHouse#110957
Detect `JSON` behind supported wrapper types so MergeTree readers reuse the part cache without changing unrelated subcolumn serialization.
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110957&sha=90a374d351eb9475c2ad4bde5c6f17cafce082a6&name_0=PR&name_1=AST%20fuzzer%20(amd_debug%2C%20targeted%2C%20old_compatibility) and provide a fix in a separate PR. It still reproduces after restoring the non- |
|
Investigated. This is a pre-existing defect on master, not caused by this PR, so your A/B holds. I reproduced it on master at Minimal repro: SET enable_nullable_tuple_type = 1;
CREATE TABLE t (`id` UInt64, `arr.id` Array(UInt64), `arr.nested` Array(Tuple(a String, b Float64)))
ENGINE = MergeTree ORDER BY id
SETTINGS share_nested_offsets = 1, min_bytes_for_wide_part = 0, min_rows_for_wide_part = 0;
INSERT INTO t SELECT number, range(number % 3), arrayMap(x -> tuple(toString(x), toFloat64(x)), range(number % 3)) FROM numbers(100);
ALTER TABLE t DROP COLUMN `arr.nested`;
ALTER TABLE t ADD COLUMN `arr.nested` Array(Nullable(Tuple(a String, b Float64)));
SELECT sum(length(nb)) FROM (SELECT id, `arr.nested`.b AS nb, `arr.id` AS aid FROM merge(currentDatabase(), '^t$'));The read hands the parent column's data back under the subcolumn's name and declared type. Four conditions are each necessary, and removing any one of them returns a correct result: Why only this PR's CI shows it: the targeted fuzzer matched 0 of your 7 changed lines against coverage and fell back to a keyword match on That fixture is not fuzzed anywhere else, which is why this type pair has 0 hits on master and 0 on any other PR over 120 days of CIDB. It is test selection, not causation. Independently of the repro, your diff cannot reach this column. Every behavioural hunk is gated on The fix belongs in the wide-part subcolumn read path in |
|
Fix: #116553 Two corrections to my comment above, since the defect turned out wider than my first reading. The site is not
Issue 113891 is still a different site and I do not claim it is fixed. |
Check regular subcolumns in the part metadata before invoking the existing serialization-based presence check. Preserve the existing lookup for dynamic paths and the custom serialization handling for `Quantize`. Cover both compact mark formats, renamed columns, and dotted-name collisions. Extend the existing performance test to both compact layouts. Local medians improved by 21% without substream marks and 55% with them; dynamic-path and wide-part controls showed no significant change. Builds and six focused checks passed. Related: ClickHouse#110957 Related: ClickHouse#113099 (review)
Includes the revert of the pre-epoch partition pruning regression that failed the integration shard. The PR patch is unchanged. ClickHouse#110957 Related: ClickHouse#119298 Related: ClickHouse#119302 https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110957&sha=b7f8a58559a910e414fe5a2e9de7852ab6f46a3c&name_0=PR&name_1=Integration%20tests%20(amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%203%2F6)
Preserve the PR changes while incorporating upstream fixes. ClickHouse#110957 https://github.com/ClickHouse/ClickHouse/pulls/rorylshanks
Reuse the same parent serialization, deserialization state, and cached column for full-column and subcolumn requests without substream marks. Copy only the current granule when the cached full column spans earlier granules. Cover both request orders and block boundaries, and add a mixed full-column/subcolumn performance query. ClickHouse#110957 (comment) Related: ClickHouse#111020 ClickHouse#110957
Reading a full `JSON` column caches the accumulated output block. Slice that cached parent to the current granule before extracting shared paths, so subsequent subcolumn reads do not repeatedly scan earlier rows. Add functional coverage for shared paths across granules and block boundaries, plus a focused performance test. With compatible existing build dependencies, seven local runs improve the full-parent/shared-path median from 4.4583 s to 0.28334 s. The subcolumns-only control has no statistically significant change. Both functional regressions pass. ClickHouse#110957 (comment)
Integrate upstream cb26a48. Preserve the existing PR history and feature scope while updating its base. Related: ClickHouse#110957 Audit: https://github.com/ClickHouse/ClickHouse/pulls/rorylshanks
|
@rorylshanks @scanhex12 @alexey-milovidov — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
…ations-in-mergetree-readers Resolved conflicts with #110957 (`JSON` subcolumn serialization cache): the general part-serialization path of this PR (`tryGetSerializationFromPart`) covers the `containsObjectType` branch added on master, so that branch is dropped. Kept master's sharing of `serializations_of_full_columns` for full-column requests in `Compact` parts and its `withRegularSubcolumns` presence checks in `MergeTreeReaderCompact`, combined with `hasSubcolumnInPart`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
IMergeTreeDataPartalready stores column and subcolumn serializations. Readers rebuilt the parentJSONserialization for requested paths instead of reusing safe cached subcolumn serializations.Reuse cached serializations when
supportsPoolingpermits sharing, including typed paths underJSONwrappers. Derive unstored paths from the cached parent. Non-poolable serializations retain per-reader construction. Wide readers skip unused full-parent serializations, and compact readers construct each full parent at most once.Compact parts with substream marks still construct one unused full-parent serialization per requested parent. Removing that remaining work is scoped to #111020. This change reduces reconstruction; it does not eliminate every parent reconstruction.
Measured CI results from
tests/performance/json_subcolumn_serialization_cache.xml, run on 2026-09-10: masterd8d2f9942e4bd888c42b7c27f3f62231b491d33dversus PRb5af97e4a163f340855413923d52aa8574068006. Values areclient_timein milliseconds. These are results from that revision, not a new measurement of the latest merge.Measured queries and CI reports. The workload reads two typed paths from a 512-path
JSONschema across 96 parts withmax_threads = 1; the results describe that workload.The Iceberg pre-epoch pruning exception in the integration report also caused the following connection failures. The latest merge includes the revert in #119298; #119302 contains the follow-up fix for that independently tracked regression.
Related: #113099
Related: #111020
Related: #119298
Related: #119302
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reduce serialization construction when reading
JSONsubcolumns fromMergeTreeparts by reusing safe cached subcolumn serializations.Workflow [PR]
Sync PR [sync-upstream/pr/110957]
Version info
26.10.1.784-master(included in26.10and later)