Skip to content

Read the change data feed of Delta Lake with our own Parquet reader - #130062

Open
alexey-milovidov wants to merge 28 commits into
masterfrom
delta-cdf-native-read
Open

alexey-milovidov wants to merge 28 commits into
masterfrom
delta-cdf-native-read

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

The change data feed of a Delta Lake table (delta_lake_snapshot_start_version / delta_lake_snapshot_end_version) was read by delta-kernel-rs itself: table_changes_scan_execute read the data files with parquet-rs and the kernel's own object store client, in a single stream, and ReadFromDeltaLakeTableChangesStep converted the Arrow batches. This was the only place where the kernel read table data rather than metadata.

Now delta-kernel-rs only lists the data files of the change data feed and resolves their deletion vectors (new FFI table_changes_scan_files_* in the fork, ClickHouse/delta-kernel-rs#21). The files are read like the data files of a snapshot, by ReadFromObjectStorageStep: in parallel, with our Parquet reader, filesystem cache and metadata caches, and with virtual columns such as _path and _file. ReadFromDeltaLakeTableChangesStep is removed.

Each file comes with the transform from the kernel, which adds the partition values and the _change_type, _commit_version and _commit_timestamp columns:

  • ExpressionVisitor supports the "replace" and "drop" field transforms, used for _change_type of CDC files, where it is a physical column.
  • DataLakeObjectMetadata::additional_file_columns: CDC files read _change_type from the file, while other data files do not have it. It is read only when the query needs it, because a column not consumed by the schema transform would pass through it.
  • DataLakeObjectMetadata::selected_rows: a pair of add/remove deletion vectors selects the changed rows instead of excluding the deleted ones; DeletionVectorTransform supports both. Such files do not use the trivial count optimization.
  • An open range of versions ends at the snapshot version pinned for the query, so the data files and the schema are read at the same version.

The change data feed is still not distributed between parallel replicas: the new per-file fields are not sent to replicas (sending an object with them throws a LOGICAL_ERROR exception).

This is the first step to move the metadata processing of Delta Lake out of delta-kernel-rs. The submodule points to the merge of ClickHouse/delta-kernel-rs#21 with the cbindgen target platform fix from master cherry-picked on top (branch cdf-scan-files-cbindgen-target of the fork). It is not the tip of ClickHouse/v0.23.0, because that branch now builds delta_kernel_ffi only as a plain lib, while ClickHouse still links its staticlib through corrosion.

Subcolumns (e.g. struct_col.field, t.x.null) are supported with the schema transform of a data lake object, also for a partitioned snapshot, which lifts the limitation of type_widening_nested in 05560_delta_lake_corpus: the transform outputs the column in storage of a requested column, passes it through if the format reads it by itself, or extracts it from the longest column or subcolumn that the transform outputs or the format reads. With column mapping, the struct fields in the transform have physical names, as in the columns read from the files.

Also fixed on the way: ExpressionVisitor swapped the halves of a Decimal128 literal (a Decimal(25, 2) partition value 1.23 was read as 22689495210662748487.68), and a CDC file, whose header has the additional _change_type column, now has its own copy of the filter info (the key condition refers to columns by position). The TopN query condition cache is not used for the change data feed, because the pinned snapshot does not identify the data files of a range of versions.

Performance: a Delta Lake table with the change data feed enabled, 32 data files of 1M rows each (584 MB, written by ClickHouse), on local disk with the page cache warm, clickhouse-local on a 96-core aarch64 machine shared with other builds; query SELECT count(), sum(v), uniqExact(s), countIf(_change_type = 'insert') FROM deltaLakeLocal(...) SETTINGS delta_lake_snapshot_start_version = 0, three runs each:

default max_threads max_threads = 1
before (master build of 2026-11-06) 28.6, 36.6, 31.4 s 25.0, 23.5, 31.4 s
after 4.1 (first run), 0.27, 0.22 s 1.34, 1.32, 1.27 s

The results are the same. The old reader did not depend on max_threads, because it read the files in one stream.

Tested locally: all clickhouse-local Delta Lake stateless tests pass, including 05530_delta_lake_kernel_cdf, which covers the change data feed of 18 tables of the kernel test data (inserts, updates, deletes by deletion vectors and CDC files, partitions, column mapping in name and id modes). 05565_delta_lake_change_data_feed_parallel_replicas (needs MinIO and a cluster) was not run locally.

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The change data feed of Delta Lake tables (delta_lake_snapshot_start_version) is read by ClickHouse's own Parquet reader, in parallel and with caches; delta-kernel-rs is used only to list the data files. Virtual columns such as _path and _file are available for it.

🤖 Generated with Claude Code


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

The change data feed of a Delta Lake table (`delta_lake_snapshot_start_version`)
was read by delta-kernel-rs itself: `table_changes_scan_execute` read the data
files with `parquet-rs` and its own object store client, in one stream, and
`ReadFromDeltaLakeTableChangesStep` converted the Arrow batches. Now
delta-kernel-rs is used only for the metadata: it lists the data files of the
change data feed and resolves their deletion vectors (new FFI
`table_changes_scan_files_*` in the fork), and the files are read like the data
files of a snapshot, by `ReadFromObjectStorageStep`, in parallel, with our
Parquet reader and caches. `ReadFromDeltaLakeTableChangesStep` is removed.

Each file comes with the transform from the kernel, which adds the partition
values and the `_change_type`, `_commit_version` and `_commit_timestamp`
columns. For that:
- `ExpressionVisitor` supports the "replace" and "drop" field transforms, which
  the kernel uses for `_change_type` of CDC files, where it is a physical column.
- `DataLakeObjectMetadata::additional_file_columns`: CDC files read
  `_change_type` from the file, while other data files do not have it.
- `DataLakeObjectMetadata::selected_rows`: a pair of deletion vectors of a file
  selects the changed rows instead of excluding the deleted ones;
  `DeletionVectorTransform` supports both.

The submodule `contrib/delta-kernel-rs` is updated to the branch `cdf-scan-files`
of the fork.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0322c43]


AI Review

Summary

Routes Delta Lake change data feed files through ReadFromObjectStorageStep, enabling parallel Parquet reads, caches, and virtual columns. Reviewed head 0322c43ef12ebea17e65a39031cb3f1d545febf9 and all replies on the 12 existing threads. The public-code fixes address the previously demonstrated failures, and the description supplies performance measurements. One previously raised integration concern still needs evidence before approval.

Consumer tracing covered selection bitmaps in DeletionVectorTransform, additional CDC columns in per-file reader headers, subcolumn extraction before projection, count shortcuts disabled for attached selections, CDF exclusion from the TopK cache, and replica-task rejection of unsupported metadata. Delta Lake declines lazy materialization through the existing metadata interface.

Findings

⚠️ Majors

  • src/Storages/prepareReadingFromFormat.h:54 and src/Storages/prepareReadingFromFormat.cpp:571: Verify the actual Cloud step-version registration and downgrade behavior. [dismissed by author -- https://github.com/Read the change data feed of Delta Lake with our own Parquet reader #130062#discussion_r4563171498] The author resolved this thread after explicitly leaving the private ReadFromObjectStorage registration outstanding; public tests do not establish that integration. The public serializer now preserves the old byte layout, but still drops columns_added_after_format at step version 0. The new unit test manually supplies version 1, so it cannot establish that real serialized reads retain this information. Losing it permits predicates on synthesized columns to reach physical-file pruning, the incorrect-result mechanism demonstrated earlier on this PR. This is an unverified integration risk, not a claim that the inaccessible private registration is definitely missing. Provide the counterpart change and a focused test through the actual step registration; verify that an older receiver either preserves the required semantics or rejects execution that cannot preserve them. No duplicate inline comment was posted.
Missing context / blind spots
  • ⚠️ The private Cloud implementation and synchronization PR were inaccessible. The author acknowledges the remaining registration requirement in the linked thread; its implementation and compatibility evidence would close this gap.
  • ⚠️ Current-head CI is incomplete: Fast test and the tidy builds passed, other builds remain in progress, and CH Inc sync reports failure without an accessible report link. The Praktika reports do not yet establish completion of the relevant Delta Lake tests. No local tests were run in this review job.
Final Verdict

Status: ⚠️ Request changes

Confirm the Cloud registration counterpart and provide focused evidence for serialized reads and older receivers. The previously fixed public-code findings do not need new inline threads.

@clickhouse-gh clickhouse-gh Bot added pr-performance Pull request with some performance improvements submodule changed At least one submodule changed in this PR. comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 8, 2026
alexey-milovidov and others added 2 commits November 8, 2026 16:29
- Update `contrib/delta-kernel-rs` to the merge of
  ClickHouse/delta-kernel-rs#21 in the branch
  `ClickHouse/v0.23.0` of the fork.
- Fix `bugprone-optional-value-conversion` in `getChangeDataFeedVersionRange`.
- Copy the column mapping of the snapshot instead of keeping a reference: the
  snapshot can be evicted from the cache of snapshots while the files are listed.
- Do not use the TopN query condition cache for the change data feed: the pinned
  snapshot does not identify the data files of a range of versions.
- Support subcolumns (e.g. `struct_col.field`) with the schema transform of a data
  lake object: the format reads a subcolumn by itself, so pass it through the
  transform, or extract it from the column that the transform makes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/Storages/ObjectStorage/StorageObjectStorageSource.cpp
@clickhouse-gh

clickhouse-gh Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 0322c43ef with master 515c1baee (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

46 object files changed (+139.95 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/DeltaLake/TableChanges.cpp.o 169.18 KiB 215.41 KiB +46.23 KiB (+27.33%)
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/DeltaLake/KernelUtils.cpp.o 212.43 KiB 237.91 KiB +25.49 KiB (+12.00%)
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/StorageObjectStorageSource.cpp.o 1.32 MiB 1.34 MiB +24.71 KiB (+1.83%)
src/CMakeFiles/dbms.dir/Storages/prepareReadingFromFormat.cpp.o 379.59 KiB 401.83 KiB +22.25 KiB (+5.86%)
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/DeltaLakeMetadataDeltaKernel.cpp.o 656.89 KiB 634.66 KiB -22.23 KiB (-3.38%)
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/DeltaLake/ExpressionVisitor.cpp.o 676.46 KiB 693.51 KiB +17.04 KiB (+2.52%)

717 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

395 translation units recompiled, 2218 s compile time in total, 395 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×0.95 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost -187.9 s (-8%) in total before that adjustment.

Symbol sizes
Binary Symbol Master PR Δ
programs/clickhouse DB::readNonNullableColumnFromArrowColumn(std::__1::shared_ptr<arrow::ChunkedArray> const&, std::__1… 70.16 KiB removed -70.16 KiB (-100.00%)

Job report

@alesapin alesapin self-assigned this Nov 9, 2026
alexey-milovidov and others added 5 commits November 9, 2026 11:47
delta-kernel-rs passes the most significant 64 bits in `value_ms` and the
least significant in `value_ls`, but `ExpressionVisitor::visitDecimalLiteral`
swapped them: a `Decimal(25, 2)` partition value `1.23` was read as
`22689495210662748487.68`. The change data feed now evaluates the transform
of each file (with the partition values) with this visitor.

Addresses review: #130062 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With column mapping, the transform of a data file (of a snapshot or of the
change data feed) had the physical names of the columns, but the logical
names of the fields of structs, while the columns read from the file and the
requested subcolumns use physical names: `t.x` is requested as `c-t.c-t-x`,
which was not found in `c-t Tuple(x ...)`. Rename the fields with
`replaceTypeNamesToPhysicalRecursively`, moved to `KernelUtils`.

Addresses review: #130062 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a transform

- A CDC file of the change data feed reads the `_change_type` column in addition
  to the columns of the format header, but the filter info (with the key
  condition, which refers to columns by positions in the header it is built for)
  was shared with the other data files: `WHERE _commit_version >= 2` threw a
  `std::out_of_range` exception in `Parquet::Reader::prefilterAndInitRowGroups`.
  Make a copy of the filter info for such a file.
- A requested subcolumn was passed through the transform by its full name even
  if the format did not read it by itself (e.g. `t.x` with `t`, or `t.x.null`,
  for which the format reads `t.x`): `NOT_FOUND_COLUMN_IN_BLOCK`. Output the
  column in storage of each requested column, and extract it from the longest
  column or subcolumn the transform outputs or the format reads. This also lifts
  the limitation of the subcolumns of partitioned tables in `05560_delta_lake_corpus`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130062&sha=6286e2160af09b9f104ece2f433b684245a00bd8&name_0=PR
PR: #130062

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 3 commits November 11, 2026 18:55
Resolve the conflict in `contrib/delta-kernel-rs`: master moved the
submodule to a cherry-pick of the cbindgen target platform fix on the old
pin, the PR to the merge of ClickHouse/delta-kernel-rs#21. Point it to the
cbindgen fix cherry-picked onto the merge of #21 (branch
`cdf-scan-files-cbindgen-target` of the fork). Not `ClickHouse/v0.23.0`,
which builds `delta_kernel_ffi` only as a plain lib, while ClickHouse still
links its staticlib through corrosion.
Master removed the `ActionsDAG.h` include from `DataLakeObjectMetadata.h`
to recompile fewer translation units, and `NamesAndTypesList` was only
available through it. Keep the header light: store
`additional_file_columns` as a `shared_ptr` to a forward-declared
`NamesAndTypesList`, null when there are no such columns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 2 commits November 13, 2026 04:29
… the format

Address review: the partition columns and the columns of the change data feed
(`_change_type`, `_commit_version`, `_commit_timestamp`) are added by the schema
transform of each data file, but the filter on them was still passed to the
Parquet reader. A data file of `cdf-table-with-cdc-and-dvs` has an incidental
physical `_change_type` column with only NULLs, so its statistics pruned the row
whose change type is `delete` in version 10 before the transform replaced the
column.

`ReadFromFormatInfo::columns_added_after_format` lists such columns, and
`getFormatFilter` drops the conjuncts on them, like for Hive partition and
virtual columns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	contrib/delta-kernel-rs
#	src/Processors/QueryPlan/ReadFromObjectStorageStep.cpp
alexey-milovidov and others added 3 commits November 14, 2026 14:19
The listing of the change data feed joined every `add.path` to the table directory, so a table that
references its data files by absolute URI (e.g. a shallow clone with `file:/...` or `s3a://...`)
could not be read. Use `IKernelHelper::resolveDataFilePath`, as the snapshot read does, which also
checks the access to the source.

Address review: #130062 (comment) PRRT_kwDOA5dJV863FZJk

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mFormatInfo`

The new field changed the bytes of an existing query-plan payload unconditionally. Write and read it
only at the step serialization version `SERIALIZATION_VERSION_WITH_COLUMNS_ADDED_AFTER_FORMAT`, so
that at an older version the bytes are unchanged and the set is read as empty (the behavior before
the field existed). The names are sorted, so the bytes do not depend on the order of the hash set.
The step that serializes this structure (`ReadFromObjectStorage`) is registered outside of this
repository, and has to register the new version to send the set.

Address review: PRRT_kwDOA5dJV863FZJp

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pinned Delta Lake metadata

With `delta_lake_reload_schema_for_consistency`, `buildStorageMetadataFromState` replaced the schema
of the change data feed with the schema of the snapshot, so `_change_type` and the other columns of
the change data feed were unknown. Build the schema of the change data feed for its version range.

Address review: PRRT_kwDOA5dJV863FZJv

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 2 commits November 16, 2026 11:22
Conflicts: `TableSnapshot.cpp` - master added `[[nodiscard]]` to `DataObjectInfo`, which this branch moved to
`DeltaLake/DataObjectInfo.h`; kept the move and added the attributes there. `ReadFromTableChangesStep.h` - removed
in this branch, kept removed.
… data feed of Delta Lake

Master enabled `modernize-use-nodiscard`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 2 commits November 19, 2026 09:21
…lumn is requested

The additional file columns of a data lake object (`_change_type` of a CDC file of the
Delta Lake change data feed) were read only when the query requested the column itself.
A request for a subcolumn such as `_change_type.size` did not read it, and the schema
transform, which extracts the subcolumn from the column, threw `NOT_FOUND_COLUMN_IN_BLOCK`.
Account for the column in storage of requested subcolumns and of the filter inputs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-delta-lake Delta Lake tables: reading Delta metadata through delta-kernel-rs (table snapshots, schema and ty... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 19, 2026
@stresshouse

stresshouse Bot commented Nov 20, 2026

Copy link
Copy Markdown

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 28 queries analysed

No query changed in a way this PR can account for. It reworks how the Delta Lake change data feed is read (it now goes through the object-storage file iterator) and touches only data-lake and object-storage code. ClickBench and TPC-H read MergeTree tables and never execute that code. The one flagged query, clickbench Q28 (-5.1%, 997.5 ms vs 1051.0 ms), stays not_sure: the result is borderline, the two tests disagree, and the baseline runs were noisy. There are no envelope-suppressed rows to check, and the era-split instability on clickbench Q22 and Q32 does not involve any flagged query.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 28 not_sure 1051 998 -5.1% <0.0001 aggregation: Q28 does a regex rewrite and GROUP BY over the MergeTree hits table, and this PR only changes Delta Lake and object-storage read code. The -5.1% delta is borderline, and the baseline runs were noisy.

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
  • StressHouse run: 69fb49be-756f-46df-bdc4-52cf76449826
  • MIRAI run: 460f7b33-85c4-4b82-bfb0-d4e8494c13f9
  • PR check IDs:
    • clickbench_444386_1795169248
    • clickbench_444392_1795169248
    • tpch_adapted_1_official_444405_1795169248
    • tpch_adapted_1_official_444411_1795169248

alexey-milovidov and others added 3 commits November 22, 2026 17:29
Conflict in `DeltaLakeMetadataDeltaKernel::getTableChanges`: master added the
session check (`checkSessionMayUseServerIdentityIgnoringSharedFlag`) to it, while
this branch made the method private and removed its `context` argument. Kept the
signature of the branch: all the callers (`getTableSchema`, `iterate`,
`buildStorageMetadataFromState`) are entrypoints that do the check themselves.
Removed the direct call of the now private method from `gtest_delta_kernel`.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…el predicate

delta-kernel splits the name of a column of the predicate by dots into a path of
struct fields, and the scan of the change data feed throws
`Predicate references unknown column: birthday.null` for a filter on the null map
of a `Nullable` column. `EnginePredicate` now gets the logical schema of the table
and references a column only if it is a column of the table or a field of its
struct; a comparison with any other subcolumn (`c.null`, `arr.size0`, `m.keys`)
is visited as an untranslated (unknown) predicate, so it does not prune anything.
The same applies to the scan of a snapshot, where the error was only logged and
the whole predicate was lost.

The scan of the change data feed also honors `delta_lake_enable_engine_predicate`.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The test was added on master and pins `DeltaLakeScannedFiles = 0` for the change
data feed, because delta-kernel-rs read its files by itself. In this branch they are
read as the data files of a snapshot and counted: one file is scanned (the one with
the inverted stats is not skipped, the other is pruned), as in the same query
without `delta_lake_snapshot_start_version`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130062&sha=04e8d56dc35708a72aa5b64d0ed1ca24b8c847f6&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29
PR: #130062

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (conflict in DeltaLakeMetadataDeltaKernel::getTableChanges with the new session check; the callers do the check, see the merge commit) and addressed the CI failures of 04e8d56:

  • 05813_delta_lake_inverted_stats_pruning: the test was added on master and pins DeltaLakeScannedFiles = 0 for the change data feed. This PR intentionally changes it: the files are read as data files and counted, so the reference is updated to 1 (e4f6811).
  • 05829_autopr_skip_index_on_read_in_subquery (plan-based parallel replicas): unrelated, fixed on master by 94e368e, which is now merged in.
  • visible_width #1 in Performance Comparison (arm_release, master_head, 7/8), +8.7%: unrelated, the PR only touches the Delta Lake reading.

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130062&sha=04e8d56dc35708a72aa5b64d0ed1ca24b8c847f6&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%207%2F8%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

Acknowledged. I'm investigating the visible_width #1 slowdown in Performance Comparison (arm_release, master_head, 7/8) on 04e8d56; I'll follow up here with a PR (or my findings) shortly.

@groeneai

Copy link
Copy Markdown
Collaborator

I agree that visible_width #1 is unrelated to this PR. The PR build runs identical code for this query from a slower address.

  • The query spends its time in DB::UTF8::computeWidth and CodePointWidthCache::get. Both functions are md5-identical (address-normalized disassembly) in the PR build and in the reference, the performance reference build of master 0f207415. In the PR build they sit 7360 bytes lower.
  • Both servers did the same work in the profile run: 5.58G vs 5.54G instructions, 1.61G vs 1.60G branches, 0.16M vs 0.17M branch misses. The PR build needed 1.13G cycles instead of 1.05G (+7.6%). The slowdown reproduced at all three stack placements of the confirm rerun (+8.8%, +8.6%, +8.6%).
  • Master's own builds show the same speeds. Since November 18, the 735 arm builds measured on this query each run it at a fixed speed (within 2.5% from job to job for the 257 builds measured more than once): about 0.375 s for most of them, 0.391 s for 24, 0.406 s for 16. The 0.406 s group includes 6 of master's performance reference builds and 2 official master builds (for example b6e4f220b7, 0.405 s). This PR build ran at 0.408 s, master's slow level. The reference ran at 0.375 s.
  • I compared 50 arm builds: the 25 PR and performance reference builds of the two slower groups, plus 25 at 0.375 s. Both functions are md5-identical in all 50. The 14 builds at 0.406 s among them are exactly the ones with computeWidth at offset 0xd40 within a 4 KiB page, and none of the other 36 has that offset. At that offset, the code that runs after each non-ASCII character is decoded (computeWidth+0x2bc..0x2c8) crosses a page boundary. I do not know the hardware reason, and this offset does not explain the 0.391 s group.

So the query and the function have nothing to fix. A build becomes slow whenever its layout puts this code at that offset, which is 1 of the 64 possible offsets of a 64-byte aligned function in a 4 KiB page. The PR's diff only shifted where its build's code landed. The dashboard blocked this at a 2.0% threshold, while master's own builds of this query differ by about 8%. No fixing PR will follow.

There has been no perf rerun yet: on e4f6811, Build (arm_tidy, 2/4) failed at EnginePredicate.cpp:197 (readability-container-contains on name.find('.') == std::string::npos, added in eefc71f), and the rest of the matrix was dropped.

alexey-milovidov and others added 3 commits November 25, 2026 05:49
Conflicts:
- `DeltaLake/TableChanges.cpp`, `DeltaLake/TableChanges.h`: master dropped the `ffi` namespace of the
  `delta-kernel-rs` header (e3e07c4) in the code which this branch replaces. Kept the rewritten
  `TableChanges` of this branch and adapted it: the kernel names are global now, and the callback of
  `table_changes_scan_files_next` takes the transform as a nullable pointer instead of an `OptionalValue`.
- `prepareReadingFromFormat.h`: kept both the new `hasDefaultOfColumnOrParent` / `defaultsDependOnTheirBlock`
  of master and `columns_added_after_format` of this branch.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… schema inference too

`DeltaLakeMetadataDeltaKernel::getTableSchema` opened a range without an end version through the latest
commit, while `iterate`, `prepareReadingFromFormat` and `buildStorageMetadataFromState` end it at the pinned
snapshot. With `delta_lake_snapshot_version` selecting a version before a commit which changes the schema,
the query failed with `Start and end version schemas are different`. Use the same end version there.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master and addressed the pending items:

  • Conflicts with e3e07c4 (the ffi namespace of the delta-kernel-rs header was dropped) in TableChanges.cpp / TableChanges.h: kept the rewritten TableChanges of this PR and adapted it to the new header; the callback of table_changes_scan_files_next now takes the transform as a nullable pointer. In prepareReadingFromFormat.h both sides are kept.
  • Build (arm_tidy, 2/4): readability-container-contains in EnginePredicate.cpp, fixed in 0681308.
  • Review: schema inference of the change data feed now ends at the pinned snapshot version (0322c43), with the new test 05875_delta_lake_cdf_schema_at_pinned_version.

Checked locally on the merged tree: clickhouse builds, gtest_delta_kernel.cpp and gtest_read_from_format_info_serialization.cpp compile, and the Delta Lake stateless tests which run with clickhouse-local pass. The tests which need a server or S3 (e.g. 05565_delta_lake_change_data_feed_parallel_replicas, 05566_delta_lake_s3_deletion_vectors_change_data_feed) were not run locally.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-delta-lake Delta Lake tables: reading Delta metadata through delta-kernel-rs (table snapshots, schema and ty... pr-performance Pull request with some performance improvements submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants