GH-49438: [C++][Gandiva] Optimize LPAD/RPAD functions#49439
Open
dmitry-chirkov-dremio wants to merge 1 commit intoapache:mainfrom
Open
GH-49438: [C++][Gandiva] Optimize LPAD/RPAD functions#49439dmitry-chirkov-dremio wants to merge 1 commit intoapache:mainfrom
dmitry-chirkov-dremio wants to merge 1 commit intoapache:mainfrom
Conversation
|
|
Author
Local Benchmark ResultsPlatform: Apple M3, macOS The original RPAD was pathologically slow compared to LPAD due to different algorithms. For 65K padding: LPAD took ~29ms while RPAD took ~992ms (34x slower for identical operation). The optimization applies the same efficient algorithm to both functions. LPAD (mean time in μs)
RPAD (mean time in μs)
|
|
|
1 similar comment
|
|
Member
|
@lriggs @akravchukdremio @xxlaykxx You may want to review this. |
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.
Rationale for this change
The
lpad_utf8_int32_utf8andrpad_utf8_int32_utf8functions have performance inefficiency and a potential memory safety issue:memsetwould suffice. Multi-byte fills use O(n) iterations instead of O(log n) with a doubling strategy.What changes are included in this PR?
std::min(fill_text_len, total_fill_bytes)for the initial copy to prevent overflowmemsetAre these changes tested?
Yes. Added tests covering:
Are there any user-facing changes?
No.