mrhhsg opened a new pull request, #68258:
URL: https://github.com/apache/doris/pull/68258

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Problem Summary:
   POW(double_column, 2.0) uses the generic binary math loop and calls libm
   pow for every row, even though squaring needs only one multiplication.
   Dispatch once per block for a constant exponent equal to 2.0, reuse the
   existing result allocation and nullable wrapper, and leave all other
   exponents and column shapes on the existing implementation. The power,
   dpow and fpow aliases share the specialization.
   
   Example:
   SELECT SUM(POW(CAST(number AS DOUBLE), 2.0))
   FROM numbers("number" = "20000000");
   
   Local ASAN (-O0) SQL timing, 2 warmups and 7 measured runs on a shared host:
   - 2,000,000 rows: median 0.491022 s -> 0.121250 s (75.31% lower latency).
   - 20,000,000 rows: median 4.618077 s -> 0.594186 s (87.13% lower latency).
   - The unchanged 20M-row exponent-3 control: 4.508301 s -> 4.501261 s.
   These are sanitizer-only sanity measurements, not RELEASE performance
   claims. ASAN does not reproduce a pow-versus-multiplication slowdown in
   the baseline; RELEASE benchmarking remains unperformed.
   
   ### Release note
   
   Improve POW/POWER/DPOW/FPOW execution with a constant exponent of 2.
   Squaring uses multiplication rounding, so floating-point last bits can
   differ from the previous libm result. NULL and special-value handling is
   preserved.
   
   ### Check List (For Author)
   
   - Test:
       - ASAN BE+FE baseline build and patched ASAN BE build passed.
       - Unit Test: ./run-be-ut.sh --run --filter='MathFunctionTest.*' -j32;
         47 passed, 1 existing release-only random_test skipped.
       - Regression test: function_p0/test_pow_square and test_math_function
         passed using an isolated local cluster. New golden output was
         generated with -forceGenOut and rerun without it; result records
         match the baseline. Only the generated extra EOF blank line was
         normalized for git diff --check.
       - clang-format v16, check-format, build hygiene and git diff --check
         passed for the changed files.
       - Changed-line clang-tidy passed with a local resource-dir correction
         and a comment-only VFS overlay for an existing unmatched NOLINTEND
         in unmodified core/types.h. Neither workaround changes repo source.
   - Behavior changed: Yes (constant-square execution and floating-point
     last-bit rounding; other exponents and NULL semantics are unchanged).
   - Does this need documentation: No
   


-- 
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]

Reply via email to