BiteTheDDDDt opened a new pull request, #60695:
URL: https://github.com/apache/doris/pull/60695
### What problem does this PR solve?
This pull request improves the performance and correctness of fixed-size
memory copy operations in hash map key handling by adding alignment-aware
logic. The main changes introduce runtime alignment checks and use compiler
hints to optimize memory copying, which can help leverage SIMD instructions and
avoid undefined behavior due to misaligned accesses.
**Hash map key handling improvements:**
* Added runtime checks for memory alignment in `MethodKeysFixed` to
determine whether to use aligned or unaligned memory copy operations, improving
safety and performance.
[[1]](diffhunk://#diff-b8623712a5a1728bb77cc67b6ee1bbf16ef2b842044f6f6bab64c3fc5c4575f3L599-R599)
[[2]](diffhunk://#diff-b8623712a5a1728bb77cc67b6ee1bbf16ef2b842044f6f6bab64c3fc5c4575f3L609-R620)
[[3]](diffhunk://#diff-b8623712a5a1728bb77cc67b6ee1bbf16ef2b842044f6f6bab64c3fc5c4575f3L720-R743)
* Refactored lambda functions in key handling logic to support
alignment-aware memory copying, replacing previous hardcoded alignment
assumptions.
[[1]](diffhunk://#diff-b8623712a5a1728bb77cc67b6ee1bbf16ef2b842044f6f6bab64c3fc5c4575f3L599-R599)
[[2]](diffhunk://#diff-b8623712a5a1728bb77cc67b6ee1bbf16ef2b842044f6f6bab64c3fc5c4575f3L609-R620)
[[3]](diffhunk://#diff-b8623712a5a1728bb77cc67b6ee1bbf16ef2b842044f6f6bab64c3fc5c4575f3L720-R743)
**Memory copy utility enhancements:**
* Updated `memcpy_fixed` in `memcpy_small.h` to use `std::assume_aligned`
for aligned copies, providing better optimization opportunities for the
compiler and ensuring correctness.
* Added `#include <memory>` to support `std::assume_aligned`.
**General code safety:**
* Added an early return in `insert_keys_into_columns` if `num_rows == 0` to
prevent unnecessary processing.
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] 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 <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]