Repository navigation
Conversation
The v3 Parquet reader appended every decoded String value with `ColumnString::insertData`, one call per row, in the three places that decode most string data: `Dictionary::appendRepeated` (an RLE run of one dictionary index), `Dictionary::appendIndexes` (a batch of dictionary indexes) and `PlainStringDecoder::decode` (a PLAIN page). Each call re-checks the chars capacity, stores the chars and offsets ends through the column and pushes one offset, and for an empty-string run (the dominant run of sparse columns) a whole run could be a single offsets fill. Append each run, batch and page at once instead: - `appendRepeated`: an empty value is `insertManyDefaults(n)`, otherwise one `chars.resize` for the whole run, `n` copies and one offsets fill. - `appendIndexes`: sum the lengths, one `chars.resize`, then copy + offset per index. - `PlainStringDecoder::decode` (no row filter, no active string filter): write values and offsets directly with the chars end in a local; when a value does not fit, commit the rows written so far and grow the chars with the same power-of-two `reserve` that `insertData` uses. Offsets are reserved before the chars grow (the order of `ColumnString::doInsertManyFrom`), and the PLAIN loop commits its prefix before each growth, so an allocation failure or a malformed page leaves a consistent column. The paths under an active `StringValueFilter` and the row-filtered PLAIN loop are unchanged. Analysis and patch by snelheidai in ClickHouse#124609. Adds `tests/performance/parquet_read_strings.xml` covering the three shapes. Closes ClickHouse#124609 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; 0 findings; 1 full pass over the whole diff, its callers and the sibling decoders). My own review of the same head found no blocker or major issue.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261009-083900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261009-051000 |
|
Workflow [PR], commit [357358e] Summary: ❌
AI ReviewSummaryReviewed #124864 at Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 16 s compile time in total, 7 of them have a recent master baseline. |
|
📊 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
|
CI finish ledger - 48409dcEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261009-133010 |
|
Fixing PR for |
…-append Resolve the conflict in `PlainStringDecoder::decode`: keep the bulk-append path for unfiltered pages, and check the length prefix before loading it there too, as master now does in every loop of the decoder (839d3eb: a page retained from a page-cache cell is not padded). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bulk append sums the lengths of all gathered dictionary entries before allocating the chars. `n` is not bounded by a page: for a single-column PREWHERE, `Reader::readRowsInPage` passes the indexes accumulated across preceding dictionary pages when the next page is PLAIN, so with a large `input_format_parquet_max_block_size` the sum can wrap `size_t` (e.g. a 2147483640-byte entry referenced 8589934625 times sums to 2^64 + 2147483384), and the copy loop then writes past the allocation. The per-value `insertData` it replaced grew the column as it went, so an allocation failure stopped it first. Accumulate starting from the current chars size with `common::addOverflow`, so one check covers both the sum and the final size, and throw `INCORRECT_DATA` before anything is allocated, as the DELTA_LENGTH_BYTE_ARRAY decoder does for its lengths. `appendRepeated` and `PlainStringDecoder::decode` stay as they are: there `n` is at most one page's value count, so `len * n` is below 2^62. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 357358eEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261118-213024 |
Closes: #124609
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reading
Stringcolumns from Parquet files is faster: a run of one dictionary value, a batch of dictionary indexes and a PLAIN page are now appended to the column at once instead of one value at a time. ClickBench queries overhits.parquetthat read sparse string columns (Q11, Q12, Q26) are 5-22% faster.Description
Analysis and patch by @ snelheidai in #124609, re-measured on x86 here.
Dictionary::appendRepeated(RLE run of one dictionary index),Dictionary::appendIndexes(batch of indexes) andPlainStringDecoder::decode(PLAIN page) calledColumnString::insertDataper value, though a run of empty strings, typical for sparse columns, is one offsets fill.Now:
appendRepeated:insertManyDefaults(n)for an empty value, else onechars.resizefor the run.appendIndexes: sum the lengths, onechars.resize, then copy per index.PlainStringDecoder::decodewithout a row filter or active string filter: write values and offsets directly, growing the chars with the same power-of-tworeserveasinsertData.Offsets are reserved before the chars grow, so an allocation failure or malformed page leaves a consistent column. The row-filtered PLAIN loop and the active
StringValueFilterbranches are unchanged.fix/base time, geomean of 8 alternating pairs, 95% CI,
max_threads = 4:Q6, Q21 and Q28 gain up to 7%; the rest, including LIKE with
apply_string_filters_during_scan = 1, are unchanged. Single-threaded peak memory is equal within 1%; with 4 threads it varies with the row groups in flight on both builds.Validation: 2240 query results over ClickHouse- and pyarrow-written files match master; Parquet stateless tests match master and pass under ASan; six mutants of the new code each fail existing tests; memory-limit and fault-injection sweeps return the correct result or
MEMORY_LIMIT_EXCEEDED. The new perf testparquet_read_stringscovers the three shapes (sparse query 0.73x).Workflow [PR]
Sync PR [sync-upstream/pr/124864]