Repository navigation
Make 04413_documentation_no_indented_lines linear in the number of lines - #127390
Merged
Merged
Conversation
…lines The lambda over all lines of a documentation entry referred to the arrays of the entry, so every array was copied for every line: quadratic in the number of lines, which reach thousands (`system.events` has about 7000). With the randomized `enable_lazy_columns_replication = 0` the copies are materialized, and the query needed about 3.9 GiB locally. In CI, where it needs a little more, it exceeded the 4.66 GiB memory limit, failing the test in many PRs and on master. Find the lines that may start a code block first, from the arrays shifted by one line, with a lambda that gets one element of each array instead of referring to whole arrays. Only these few lines (56 of about 180000) look up their container, which is also computed once instead of four times. The query now needs about 30 MiB with or without lazy replication. The result is the same: compared with the old query on 150000 random Markdown-like descriptions.
Contributor
|
Workflow [PR], commit [45324f3] Summary: ✅ AI ReviewSummaryReworks Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
rienath
approved these changes
Oct 22, 2026
Contributor
Author
|
Related fix in #116577 alongside more changes. |
cv4g
enabled auto-merge
October 22, 2026 12:15
1 task done
clickhouse-gh Bot
added a commit
that referenced
this pull request
Nov 20, 2026
Backport #127390 to 26.10: Make `04413_documentation_no_indented_lines` linear in the number of lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
04413_documentation_no_indented_linesfailing withMEMORY_LIMIT_EXCEEDED:Since 2026-10-20 the test exceeds the 4.66 GiB memory limit in many PRs and on master (e.g. #110548, #115605, #124893, #126971, #127220), whenever the randomized settings include
enable_lazy_columns_replication = 0. CI reproduces it with that setting and passes without it.CIDB: https://play.clickhouse.com/play?user=play&run=1&tab=Query%20C#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIHRvU3RhcnRPZkRheShjaGVja19zdGFydF90aW1lKSBBUyBkYXksCiAgICBjb3VudCgpIEFTIGZhaWx1cmVzLAogICAgZ3JvdXBVbmlxQXJyYXkocHVsbF9yZXF1ZXN0X251bWJlcikgQVMgcHJzLAogICAgYW55KHJlcG9ydF91cmwpIEFTIHJlcG9ydF91cmwKRlJPTSBjaGVja3MKV0hFUkUgKG5vdygpIC0gdG9JbnRlcnZhbERheShpbnRlcnZhbF9kYXlzKSkgPD0gY2hlY2tfc3RhcnRfdGltZQogICAgQU5EIHRlc3RfbmFtZSA9ICcwNDQxM19kb2N1bWVudGF0aW9uX25vX2luZGVudGVkX2xpbmVzJwogICAgLS0gQU5EIGNoZWNrX25hbWUgPSAnU3RhdGVsZXNzIHRlc3RzIChhbWRfZGVidWcsIHBhcmFsbGVsKScKICAgIEFORCB0ZXN0X3N0YXR1cyBJTiAoJ0ZBSUwnLCAnRVJST1InKQogICAgQU5EIChwdWxsX3JlcXVlc3RfbnVtYmVyID0gMCBPUiBiYXNlX3JlZiBJTiAoJ21hc3RlcicpKQogICAgQU5EIHRlc3RfY29udGV4dF9yYXcgTElLRSAnJXJldHVybiBjb2RlJScKR1JPVVAgQlkgZGF5Ck9SREVSIEJZIGRheSBERVNDCg==
The query checked every line of every documentation entry in a lambda that refers to the per-line arrays of the entry, so each array was copied for every line: quadratic in the number of lines, and
system.eventsalone has about 7000. With lazy replication disabled these copies are materialized.The query now:
system.documentation, and only once per candidate instead of four times.For an entry with n lines and k candidates this is O(n + k * n) instead of O(n²).
max_memory_usage,enable_lazy_columns_replication = 1max_memory_usage,enable_lazy_columns_replication = 0The rule the test checks is unchanged:
Related: https://github.com/ClickHouse/ClickHouse/actions/runs/39757783682/job/119767959935
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/127390]
Version info
26.11.1.554-master(included in26.11and later)26.10.9.13