Skip to content

[branch-4.1](variant) Skip full footer scan when constructing VariantStatsCaculator (#62819)#63072

Merged
yiguolei merged 1 commit into
apache:branch-4.1from
csun5285:pick-62819-to-4.1
May 9, 2026
Merged

[branch-4.1](variant) Skip full footer scan when constructing VariantStatsCaculator (#62819)#63072
yiguolei merged 1 commit into
apache:branch-4.1from
csun5285:pick-62819-to-4.1

Conversation

@csun5285
Copy link
Copy Markdown
Contributor

@csun5285 csun5285 commented May 8, 2026

pick from master #62819

…culator (apache#62819)

In **vertical compaction**, `SegmentWriter::init()` is called multiple
times against the same writer (key columns first, then each value-column
group). The footer **accumulates** across calls, so every additional
`init()` re-scans an ever-larger footer — including entries from prior
`init()`s that the current `column_ids` cannot address.

| | Before | After |
|---|---|---|
| Single construction | O(footer accumulated size) | O(this init's
column_ids size) |
| N vertical-compaction `init()` calls | **O(N²)** | **O(N)** |

Snapshot `_footer.columns_size()` **before** `_create_writers` appends
new entries and pass it to `VariantStatsCaculator` as
`footer_column_offset`. The constructor only walks `[offset, end)` — its
own slice.

When performing compaction with 10,000 columns in the variant, this
method accounts for around 8% of CPU usage. After changing it to O(N),
this section has disappeared from the flame graph.

(cherry picked from commit ffefcae)
@csun5285 csun5285 requested a review from yiguolei as a code owner May 8, 2026 07:08
@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@csun5285
Copy link
Copy Markdown
Contributor Author

csun5285 commented May 8, 2026

run buildall

@csun5285 csun5285 changed the title [fix](variant) Skip full footer scan when constructing VariantStatsCaculator (#62819) [branch-4.1](variant) Skip full footer scan when constructing VariantStatsCaculator (#62819) May 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

PR approved by at least one committer and no changes requested.

@github-actions github-actions Bot added approved Indicates a PR has been approved by one committer. reviewed labels May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit d159a61 into apache:branch-4.1 May 9, 2026
28 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants