Skip to content

[GLUTEN-10833][VL] Reduce memcpy in ColumnToRow#10824

Merged
zhouyuan merged 2 commits intoapache:mainfrom
zhouyuan:wip_c2r_memcpy
Oct 16, 2025
Merged

[GLUTEN-10833][VL] Reduce memcpy in ColumnToRow#10824
zhouyuan merged 2 commits intoapache:mainfrom
zhouyuan:wip_c2r_memcpy

Conversation

@zhouyuan
Copy link
Member

@zhouyuan zhouyuan commented Sep 30, 2025

What changes are proposed in this pull request?

We always fill the buffer with 0 so it's no necessary to keep the old content when doing allocation in C2R

Fixes #10833

How was this patch tested?

pass GHA

@github-actions github-actions bot added the VELOX label Sep 30, 2025
@zhouyuan zhouyuan changed the title [VL] Reduce memcpy in c2r [VL] Reduce memcpy in ColumnToRow Oct 2, 2025
@zhouyuan zhouyuan changed the title [VL] Reduce memcpy in ColumnToRow [GLUTEN-10833][VL] Reduce memcpy in ColumnToRow Oct 2, 2025
@zhouyuan zhouyuan marked this pull request as ready for review October 2, 2025 09:16
@zhouyuan zhouyuan requested a review from JkSelf October 2, 2025 09:16
@github-actions
Copy link

github-actions bot commented Oct 2, 2025

#10833

veloxBuffers_ = velox::AlignedBuffer::allocate<uint8_t>(totalMemorySize, veloxPool_.get());
} else if (veloxBuffers_->capacity() < totalMemorySize) {
velox::AlignedBuffer::reallocate<uint8_t>(&veloxBuffers_, totalMemorySize);
veloxBuffers_.reset();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need reset?

Copy link
Member Author

Choose a reason for hiding this comment

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

this will ensure the buffer allocated previously released

Copy link
Contributor

Choose a reason for hiding this comment

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

@zhouyuan The resource will be automatically released when the smart pointer is assigned a new value, as the assignment operator handles the reference counting internally. We can simplify the code to:

if (veloxBuffers_ == nullptr || veloxBuffers_->capacity() < totalMemorySize) {
    veloxBuffers_ = velox::AlignedBuffer::allocate<uint8_t>(totalMemorySize, veloxPool_.get());
}

Copy link
Member Author

Choose a reason for hiding this comment

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

@zhouyuan zhouyuan force-pushed the wip_c2r_memcpy branch 2 times, most recently from 1f62c20 to 644ee51 Compare October 13, 2025 13:52
We always fill the buffer with 0 so it's no necessary to keep the old content when doing allocation in C2R

Signed-off-by: Yuan <yuanzhou@apache.org>
@github-actions
Copy link

Run Gluten Clickhouse CI on x86

Signed-off-by: Yuan <yuanzhou@apache.org>
Copy link
Contributor

@JkSelf JkSelf left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your improvement.

@zhouyuan zhouyuan merged commit 5d79530 into apache:main Oct 16, 2025
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VL] Improve columnar to row memory allocation

3 participants