Skip to content

Load marks asynchronously by default - #118477

Merged
alexey-milovidov merged 1 commit into
masterfrom
load-marks-asynchronously-by-default
Sep 7, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
load-marks-asynchronously-by-default

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

Related: #118475

The setting load_marks_asynchronously was false by default (ClickHouse Cloud already uses true). In the synchronous mode, the marks of every substream are loaded in the reading thread one after another, which is one network round trip per substream on object storage. Reading one row of a JSON column with about 250 paths (about 500 substreams per part) from a public S3 bucket took minutes, and almost all of that time was WaitMarksLoadMicroseconds. With the asynchronous mode, the marks of all streams of a part are loaded in parallel by the marks loading thread pool.

Controlled benchmark from the issue (one Wide part with 1104 substreams behind a 30 ms per request HTTP server, SELECT * ... ORDER BY t DESC LIMIT 1): 64 to 67 s with the synchronous mode, 2.5 s with the asynchronous mode.

Changelog category (leave one):

  • Performance Improvement

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

Load marks of MergeTree parts asynchronously by default (setting load_marks_asynchronously), so the marks of all streams are loaded in parallel. This makes reading columns with many substreams (such as JSON) from object storage much faster.


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

Version info

  • Merged into: 26.9.1.914 (included in 26.9 and later)

The setting `load_marks_asynchronously` was `false` by default (ClickHouse
Cloud has `true`). With the synchronous mode, the marks of every substream are
loaded in the reading thread one after another, which is one network round trip
per substream on object storage. Reading one row of a `JSON` column with ~250
paths (~500 substreams per part) from a public S3 bucket took minutes; with the
asynchronous mode the marks of all streams are loaded in parallel by the marks
loading thread pool.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5a771e4]

Summary: ✅


AI Review

Summary

This PR flips the default of load_marks_asynchronously to true, updates the source-level setting documentation, and records the default change in SettingsChangesHistory.cpp so compatibility can still restore the old behavior for older versions. I did not find an unresolved correctness, compatibility, or evidence gap in the current diff; the linked issue includes concrete before/after measurements, and the current Praktika run is all green.

Final Verdict

Status: ✅ Approve

LLVM Coverage Report

Measured on commit 5a771e4.

Metric Baseline Current Δ
Lines 88.80% 88.80% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.10% 81.20% +0.10%

Changed lines: Changed C/C++ lines covered: 15/15 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Sep 6, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Sep 6, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 5a771e48c with master e212a8e87 (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.

Compile time of recompiled translation units

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

Job report

@clickhouse-gh

clickhouse-gh Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

🟢 AI verdict: improvement — 1 query(s) improved out of 40 analysed

1 improved query(s). K_source=6 K_base=30 flagged=1/65

clickbench

🟢 1 improved · ⚠️ 2 inconclusive

Flagged queries (3 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
🟢 31 improvement 309 270 -12.6% <0.0001
⚠️ 18 not_sure 1082 922 -14.7% <0.0001
⚠️ 32 not_sure 1362 777 -43.0% <0.0001

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: 98e91031-b6d9-4f9d-b473-0dff3d3114a9
  • MIRAI run: ed1b1cfd-8277-41bb-b2da-4d47041a0e49
  • PR check IDs:
    • clickbench_1456787_1788743015
    • clickbench_1456975_1788743022
    • clickbench_1457107_1788743086
    • tpch_adapted_1_official_1457210_1788743097
    • tpch_adapted_1_official_1457312_1788743101
    • tpch_adapted_1_official_1457424_1788743114

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Sep 7, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 7, 2026
Merged via the queue into master with commit 7dc47a0 Sep 7, 2026
174 checks passed
@alexey-milovidov
alexey-milovidov deleted the load-marks-asynchronously-by-default branch September 7, 2026 16:27
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. pr-performance Pull request with some performance improvements 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.

2 participants