From be501916a85d31336fea4b924aa324abe7d52f33 Mon Sep 17 00:00:00 2001 From: Mryange Date: Fri, 30 Oct 2026 09:55:09 +0800 Subject: [PATCH] [opt](column) Inline column creation to enable cast vectorization (#69840) ### What problem does this PR solve? Issue Number: N/A Problem Summary: Some simple CAST loops remain scalar because `COWHelper::create(Args&&...)` is not inlined. Root cause: forwarding a row-count lvalue passes its address to the factory. When output stores may alias that escaped variable, the compiler cannot prove the loop bound is invariant and reports `UnsupportedUncountableLoop`. On x86 with Clang 20.1.8, `-O3` and AVX2, the factory exceeds the inline threshold for INT-to-BIGINT (cost 260 vs. 250) and numeric/Decimal-to-BOOLEAN (255 vs. 250). This is not ARM-specific. Mark the small factory wrapper `ALWAYS_INLINE` so the compiler can see through column construction and optimize affected callers. ### Release note None ### Check List (For Author) - Test - [x] Manual test: compiled `function_cast_int.cpp` before/after with Clang optimization remarks and inspected assembly. The non-null INT-to-BIGINT loop changes from scalar code to AVX2 `vpmovsxdq`, with vectorization width 4 and interleave count 4. The null-map path still has a separate vectorization blocker. - [x] Manual test: diagnostic compilation of `function_cast_bool.cpp` confirms the same escaped-bound blocker in 26 numeric/Decimal-to-BOOLEAN instances; an isolated temporary-row-count experiment removes that blocker. This BOOLEAN experiment validates the cause, not the final patch across every instance. - [x] Formatting, `git diff --check`, and `build-support/check-build-hygiene.sh` passed. - Full BE build, runtime benchmarks, SQL regression tests and ARM recompilation were not run. In the INT translation-unit experiment, object text grows from 448,711 to 478,128 bytes (about 6.6%); runtime speedup has not been measured. - Behavior changed: - [x] No. SQL conversion semantics are unchanged. - Does this need documentation? - [x] No. ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label --- be/src/core/cow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/be/src/core/cow.h b/be/src/core/cow.h index 31daddc5c4e..da0643c796d 100644 --- a/be/src/core/cow.h +++ b/be/src/core/cow.h @@ -430,7 +430,7 @@ public: // | ~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~ // ColumnPtr res_data_column = ColumnUInt8::create(1, 1); template - static MutablePtr create(Args&&... args) { + ALWAYS_INLINE static MutablePtr create(Args&&... args) { return MutablePtr(new Derived(std::forward(args)...)); } #include "common/compile_check_avoid_end.h"