Skip to content

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

Open
csun5285 wants to merge 2 commits intoapache:branch-4.0from
csun5285:pick-62819-to-4.0
Open

[branch-4.0](variant) Skip full footer scan when constructing VariantStatsCaculator (#62819)#63113
csun5285 wants to merge 2 commits intoapache:branch-4.0from
csun5285:pick-62819-to-4.0

Conversation

@csun5285
Copy link
Copy Markdown
Contributor

pick from master #62819

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

…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)
@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

run buildall

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

run buildall

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants