This is an automated email from the ASF dual-hosted git repository.

hello-stephen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 0127314e7a5 [opt](exec) optimize fixed key packing (#65572)
0127314e7a5 is described below

commit 0127314e7a50fd43fa9a8b959bb73ba600fb304b
Author: Mryange <[email protected]>
AuthorDate: Tue Jul 28 10:39:16 2026 +0800

    [opt](exec) optimize fixed key packing (#65572)
    
    ### What problem does this PR solve?
    
    Fixed-key packing could lose `restrict` alias information when the
    source data pointer was captured by reference in an outlined lambda,
    producing a less efficient copy loop. This change obtains the restricted
    pointer inside the lambda after nullable key replacement, preserving
    alias information without changing the key encoding or query behavior.
---
 be/src/exec/common/hash_table/hash_map_context.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/be/src/exec/common/hash_table/hash_map_context.h 
b/be/src/exec/common/hash_table/hash_map_context.h
index 1dc33319dfe..9c5bbab2101 100644
--- a/be/src/exec/common/hash_table/hash_map_context.h
+++ b/be/src/exec/common/hash_table/hash_map_context.h
@@ -947,17 +947,21 @@ struct MethodKeysFixed : public MethodBase<TData> {
         }
 
         for (size_t j = 0; j < key_columns.size(); ++j) {
-            const char* __restrict data = key_columns[j]->get_raw_data().data;
-
             auto goo = [&]<typename Fixed, bool aligned>(Fixed zero) {
                 CHECK_EQ(sizeof(Fixed), key_sizes[j]);
                 if (has_null_column.size() && has_null_column[j]) {
                     const auto* nullmap =
                             assert_cast<const 
ColumnUInt8&>(*nullmap_columns[j]).get_data().data();
                     // make sure null cell is filled by 0x0
+                    // This mutates the same underlying buffer returned by 
get_raw_data(), so get
+                    // the restricted data pointer only after the replacement 
finishes.
                     
const_cast<IColumn*>(key_columns[j])->replace_column_null_data(nullmap);
                 }
                 auto* __restrict current = result_data + offset;
+                // Do not hoist data out of goo. A reference capture is 
lowered to an ordinary
+                // closure field, so restrict/noalias information is lost when 
goo is not inlined,
+                // which prevents the copy loop from being optimized.
+                const char* __restrict data = 
key_columns[j]->get_raw_data().data;
                 for (size_t i = 0; i < row_numbers; ++i) {
                     memcpy_fixed<Fixed, aligned>(current, data);
                     current += sizeof(T);
@@ -969,6 +973,7 @@ struct MethodKeysFixed : public MethodBase<TData> {
                 // Also verify that the stride sizeof(T) is a multiple of 
alignof(Fixed),
                 // otherwise alignment will be lost on subsequent loop 
iterations
                 // (e.g. UInt96 has sizeof=12, stride 12 is not a multiple of 
alignof(uint64_t)=8).
+                const char* data = key_columns[j]->get_raw_data().data;
                 if (sizeof(T) % alignof(Fixed) == 0 &&
                     reinterpret_cast<uintptr_t>(result_data + offset) % 
alignof(Fixed) == 0 &&
                     reinterpret_cast<uintptr_t>(data) % alignof(Fixed) == 0) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to