Skip to content

Apply -WithMemoryTracking containers to src/Processors/Formats - #126530

Merged
nickitat merged 17 commits into
masterfrom
wmt_processors_formats
Nov 9, 2026
Merged

nickitat merged 17 commits into
masterfrom
wmt_processors_formats

Conversation

@nickitat

@nickitat nickitat commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Workflow [PR]
Sync PR [sync-upstream/pr/126530]

Version info

  • Merged into: 26.11.1.1727-master (included in 26.11 and later)

nickitat and others added 2 commits October 17, 2026 19:32
Replace `std::` containers in `src/Processors/Formats` with their
`-WithMemoryTracking` counterparts and enable the lint for the directory.
Types are propagated to their owners (`src/Formats`, `Storages`), so no
copies are introduced at the boundaries. Containers passed to Arrow, ORC,
Avro, Parquet or Protobuf APIs, and the `Names`/`Strings`/`DataTypes`
aliases stay as they are. Vectors of chunks use the `Chunks` alias.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT
# Conflicts:
#	ci/jobs/scripts/check_style/check_cpp.sh
#	src/Processors/Formats/Impl/Parquet/PrepareForWrite.cpp
#	src/Processors/Formats/Impl/Parquet/Reader.cpp
#	src/Processors/Formats/Impl/ParquetV3BlockInputFormat.cpp
#	src/Server/ArrowFlight/ArrowFlightServer.cpp
@nickitat nickitat changed the title Use -WithMemoryTracking containers in src/Processors/Formats Apply -WithMemoryTracking containers to src/Processors/Formats Oct 17, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cc0ae53]

Summary: ✅


AI Review

Summary

The PR migrates format-processing containers and dependent APIs to memory-tracked allocators so allocations enforce memory limits. Reviewed the full diff and prior discussion against head cc0ae531cf6b4f2f43112732956e7c538a1aa180. The earlier Prefetcher::registerRange cleanup, Vortex converter-cache cleanup, and parseThrift error-code findings are fixed. No new or remaining actionable findings.

Missing context / blind spots
  • ⚠️ No local builds or tests were run. Current CI reports Fast test passing, but unit and stress tests remain pending. Their results are still needed to confirm the allocation-failure regression tests and sanitizer coverage.
Final Verdict

Status: ✅ Approve. No review changes requested; runtime validation remains subject to the pending CI jobs.

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). labels Oct 17, 2026
Resolve conflicts with master's Parquet reader rewrite and the native `ORC` reader, and convert the
`std::` containers master added to `src/Processors/Formats` since the previous merge (`ORC`, Parquet
`FileFooter`/column chunks/read-ahead, `ParquetMetadataCache`, Vortex, `ArrowBatchRowLimit`, Avro) to
their `-WithMemoryTracking` counterparts, along with the callers that receive them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT
@clickhouse-gh

clickhouse-gh Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing cc0ae531c with master 1aa0ce969 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

614 object files changed (+327.98 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/Parquet/Reader.cpp.o 949.95 KiB 970.02 KiB +20.07 KiB (+2.11%)
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/AvroRowInputFormat.cpp.o 1.09 MiB 1.11 MiB +19.16 KiB (+1.71%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

3383 translation units recompiled, 18186 s compile time in total, 3382 of them have a recent master baseline.

Translation units without a recent master baseline:

  • programs/keeper/Keeper.cpp (clickhouse-keeper): 7.7 s
Symbol sizes
Binary Symbol Master PR Δ
programs/clickhouse DB::readNonNullableColumnFromArrowColumn(std::__1::shared_ptr<arrow::ChunkedArray> const&, std::__1… 66.05 KiB removed -66.05 KiB (-100.00%)
programs/clickhouse DB::readNonNullableColumnFromArrowColumn(std::__1::shared_ptr<arrow::ChunkedArray> const&, std::__1… new 65.80 KiB +65.80 KiB

Job report

nickitat and others added 3 commits November 5, 2026 13:09
…n a prefetch request

`VortexBlockInputFormat::returnConverter` grows `converters`, which now throws on the memory limit;
calling it from `SCOPE_EXIT` would terminate. Return the converter on success only.

`Prefetcher::registerRange` now creates the `PrefetchHandle` before growing the range vector, so a
throw cancels the request instead of tripping the destructor's assertion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT
Rejects every allocation of one `registerRange` call after 0 to 63 successful ones, so some calls fail while
growing the range vector after the request is inserted. Without the `PrefetchHandle` created before the
growth, the destructor of `Prefetcher` finds a request that is not cancelled: with that check made fatal in a
release build the test aborts, with the fix it passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT
nickitat and others added 2 commits November 5, 2026 18:09
…metadata

The column chunk offsets are tracked containers now, so the parsing can throw `MEMORY_LIMIT_EXCEEDED`, which
`parseThrift` turned into `STD_EXCEPTION`. Rethrow `DB::Exception` as is. Without the fix the new test gets 1001.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT
@nickitat
nickitat marked this pull request as ready for review November 5, 2026 19:28
@nickitat
nickitat requested a review from azat November 5, 2026 19:28
…llback

The GeoParquet metadata parse, the row-group statistics and the column index of
`covering.bbox` columns fall back to no spatial pruning on malformed input. Their
containers now throw `MEMORY_LIMIT_EXCEEDED`, which was treated as malformed input:
the query succeeded with pruning silently disabled. Rethrow it instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT
@azat azat self-assigned this Nov 5, 2026
Resolve conflicts with the new `RelativePathWithMetadata` and `ContextPtr`
parameters of `IBucketSplitter::splitToBuckets` by keeping the tracked return
type, and adapt the new `TestFileBucketInfo` override in
`gtest_rendezvous_hashing.cpp` to the tracked `filterByMatchingRowGroups`
parameter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT

@azat azat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly OK, I've left a few comments will be nice to address some that are more important before merging

Also maybe we can add few typedes (but it is up to you):

  • for ORC positions
  • for column mapping, i.e. set<String, UInt64> and back
  • Parquet row groups and column indexes

Comment thread src/Common/GeoBbox.h Resolved
Comment thread src/Formats/ColumnMapping.cpp Resolved
Comment thread src/Formats/ColumnMapping.cpp Resolved
nickitat and others added 3 commits November 6, 2026 22:38
`Footer::parse` came from master with a `std::vector`, which the container lint
of `src/Processors` rejects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT
- `ColumnMapping::insertDefaultsForNotSeenColumns` takes `std::span<UInt8>`, and
  `JSONCompactEachRowRowOutputFormat::writeLine` and
  `JSONUtils::makeNamesValidJSONStrings` take `std::span<const String>`, like the
  other `writeLine` overloads.
- Remove the `<vector>`, `<unordered_map>` etc. includes whose last use this PR
  converted, the `-WithMemoryTracking` includes that have no user, and the ones a
  `.cpp` already gets from its own header.
- Move the `-WithMemoryTracking` includes of files guarded by `USE_...` inside the
  guard.
- Add aliases for the repeated types: `ORC::RowGroupPositions`,
  `ColumnNameToFieldId`, `FieldIdToColumnName` and `ColumnNameMap` (in the new
  `Formats/ColumnNameMaps.h`), `RowGroupIndices`, `Parquet::ColumnIndices` and
  `Parquet::ColumnChunkOffsets`.

#126530 (review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT
@nickitat
nickitat enabled auto-merge November 6, 2026 23:50
@nickitat
nickitat disabled auto-merge November 7, 2026 00:34
@nickitat
nickitat enabled auto-merge November 7, 2026 22:07
nickitat and others added 3 commits November 8, 2026 11:43
# Conflicts:
#	src/Processors/Formats/Impl/Parquet/Reader.cpp
Conflicts in the includes of `AvroRowInputFormat.cpp` and `VariantEncoding.cpp`
and in `SchemaProcessor.h`: kept master's code without the includes that are no
longer used, and `ColumnNameToFieldId` for `traverseSchema`. Also used
`VectorWithMemoryTracking` for the new `stripe_first_rows` in the ORC reader.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DFFRj3kqWUsA1C3A8DapeT
@nickitat
nickitat added this pull request to the merge queue Nov 9, 2026
Merged via the queue into master with commit 1d607cb Nov 9, 2026
188 checks passed
@nickitat
nickitat deleted the wmt_processors_formats branch November 9, 2026 05:24
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 9, 2026
alexey-milovidov added a commit that referenced this pull request Nov 9, 2026
…-parallel-read

Conflicts were caused by #126530,
which moved Parquet reading and `IInputFormat` to `VectorWithMemoryTracking`
and related aliases (`ColumnIndices`, `RowGroupIndices`,
`UnorderedSetWithMemoryTracking`). Kept the PR's code (`splitForParallelReading`,
`SharedFileColumnChunks`, `collectSortedMetadataOffsets`) and converted its
containers to the new types, also in `ReadManager.cpp` and `StorageFile`.
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 11, 2026
…p-k-string-decode-bound

Resolve conflicts with ClickHouse#129882 and ClickHouse#126530: `optimize` takes both
`top_k_filter_column` and `top_k_string_sort_column`, the step predicates
keep both conditions, and `get_columns_written_to_cache` returns master's
`VectorWithMemoryTracking<bool>`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 11, 2026
…cache

The style check now requires the `-WithMemoryTracking` containers in
`src/Processors/Formats` (ClickHouse#126530). The row block bitmaps passed through
`IInputFormat::getMatchedRowBlocks` / `setRowBlocksToRead` become
`VectorWithMemoryTracking<bool>`, and `QueryConditionCache::readFile`
converts the stored marks to it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano pushed a commit that referenced this pull request Nov 11, 2026
The conflicts come from the `-WithMemoryTracking` containers of #126530,
which 26.10 does not have: the new code uses std::unordered_set and
std::vector, like the rest of the file on 26.10.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano pushed a commit that referenced this pull request Nov 11, 2026
The conflicts come from the `-WithMemoryTracking` containers of #126530,
which 26.9 does not have: the new code uses std::unordered_set and
std::vector, like the rest of the file on 26.9.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano pushed a commit that referenced this pull request Nov 11, 2026
The conflicts come from the `-WithMemoryTracking` containers of #126530
and from `findORCStructFieldByName` of #109741, which 26.8 does not have:
the new code uses std::unordered_set and std::vector, and the recursive
call keeps the name lookup of 26.8.

The test enables `enable_nullable_tuple_type`, which is off by default on
26.8, and drops the five queries that read a subcolumn through a list
(`tb.l.b`, `an.x.v`): 26.8 returns empty arrays for such a path even for
a field that is in the file, with or without this change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano pushed a commit that referenced this pull request Nov 11, 2026
The conflicts come from the `-WithMemoryTracking` containers of #126530,
which 26.3 does not have, and from `unwrapORCNullableTuple`, which 26.3
still has next to the new function: the new code uses std::unordered_set
and std::vector, and both functions are kept.

The test enables `allow_experimental_nullable_tuple_type`, which is off
by default on 26.3, and drops seven queries that fail on 26.3 with or
without this change: the five that read a subcolumn through a list
(`tb.l.b`, `an.x.v`, which 26.3 returns as empty arrays even for a field
that is in the file), and the two that read a field of the NULL struct
`ts` that is in the file as a non-Nullable element of a Nullable Tuple
(by name and by position), which 26.3 rejects with
CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN, also when every field is
requested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Nov 12, 2026
The style check now requires `src/Processors/Formats` to use the
`-WithMemoryTracking` aliases instead of standard containers
(#126530).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111932&sha=latest&name_0=PR&name_1=Style%20check
PR: #111932

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov alexey-milovidov mentioned this pull request Nov 12, 2026
1 task done
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 12, 2026
Two semantic conflicts with master made the merge-queue run fail
(MergeQueueCI run 43079186130, merge commit 9948f7e):

- ClickHouse#129121 added a call to `reinterpretRawByteColumns` for native
  GeoArrow columns, while this branch gave that function a
  `repair_variants` parameter. Pass `true`, as the other materialized
  column call in `buildChunk` does; the geo target type has no
  `Variant`, so the value does not change the result.
- ClickHouse#126530 extended the `-WithMemoryTracking` container style rule to
  `src/Processors/Formats`; use `VectorWithMemoryTracking` in
  `variantElementTargets`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 16, 2026
Master now enforces clang-tidy `modernize-use-nodiscard` (ClickHouse#126158), so the
`canRejectValues` overrides get `[[nodiscard]]` like the neighbouring
`isTrivial` overrides, and bans plain `std::vector` in `src/Processors/Formats`
(ClickHouse#126530), so the decode ranges use `VectorWithMemoryTracking`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants