Impala Public Jenkins has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/24997 )
Change subject: IMPALA-11917: Codegen branch-free reads of nullable scalar slots ...................................................................... IMPALA-11917: Codegen branch-free reads of nullable scalar slots After the LLVM 22 upgrade, TPC-DS Q99's streaming aggregation was ~20% slower than with LLVM 5. Its UpdateTuple compiled to 269 instructions with 22 branches (LLVM 5: 84 instructions, 5 branches). GetSlotRef wraps each slot read in a null-check diamond. Once several reads of the same slots are inlined into a single function, LLVM 22 no longer merges these diamonds. Each read keeps its own branch and conditional load, and the packed *Val is rebuilt via shifts and cmovs. Replacing the phi with a select after the branch doesn't help, because InstCombine converts a select back into a phi when a dominating branch tests the same condition. When the tuple is not nullable and the slot is a nullable simple scalar (i.e. not string, timestamp, collection, struct or variant), GetSlotRef now loads the slot unconditionally and selects on the null bit. This is safe because the slot is always within the tuple's memory. With no branch on the null bit, LLVM combines the null checks and CSEs the loads across expressions, so UpdateTuple compiles to 88 instructions with 6 branches. 09:AGGREGATE STREAMING in Q99 drops from 39-41ms to 32-33ms, matching LLVM 5. Codegen for other types didn't change as they showed no improvement. Testing: - Q99 results on tpcds20_parquet match with codegen enabled and disabled. - Ran tests/query_test/test_tpcds_queries.py. Change-Id: I6edaf90100cc3360a7c93d3218eb6956fcec24f0 Assisted-by: Claude Opus 5.5 (GitHub Copilot) Reviewed-on: http://gerrit.cloudera.org:8080/24997 Reviewed-by: Michael Smith <[email protected]> Reviewed-by: Joe McDonnell <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- M be/src/codegen/codegen-anyval.cc M be/src/codegen/codegen-anyval.h M be/src/exprs/slot-ref.cc M be/src/exprs/slot-ref.h 4 files changed, 90 insertions(+), 1 deletion(-) Approvals: Michael Smith: Looks good to me, but someone else must approve Joe McDonnell: Looks good to me, approved Impala Public Jenkins: Verified -- To view, visit http://gerrit.cloudera.org:8080/24997 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I6edaf90100cc3360a7c93d3218eb6956fcec24f0 Gerrit-Change-Number: 24997 Gerrit-PatchSet: 13 Gerrit-Owner: Michael Smith <[email protected]> Gerrit-Reviewer: Csaba Ringhofer <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Joe McDonnell <[email protected]> Gerrit-Reviewer: Michael Smith <[email protected]> Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]>
