Balazs Hevele has uploaded this change for review. ( 
https://gerrit.cloudera.org/25627


Change subject: IMPALA-15517: Add short circuit evaluation to codegened 
compounds
......................................................................

IMPALA-15517: Add short circuit evaluation to codegened compounds

Before this, when evaluating an AndPredicate or OrPredicate, the
interpreted path had short circuit evaluation, while the codegen path
always evaluated both LHS and RHS in all cases.
SQL allows both behaviors, but this difference meant the query's result
could be different in codegen and interpreted path e.g. when evaluating
RHS would yield an error.

After the change, the codegen path mirrors the interpreted path's short
circuit evaluation, i.e.:
-for AND, LHS is evaluated first, and RHS is only evaluated if LHS is
not false
-for OR, LHS is evaluated first, and RHS is only evaluated if LHS is not
true

Testing:
-Added cases to exprs.test that validate an RHS yielding an error does
not get evaluated if the LHS decides the value or the predicate.

Performance:
-Measured on 6M rows (release build, single node) with cheap
(int compare) and expensive (regexp_replace) predicates.
-With an expensive RHS, time drops in proportion to the fraction of rows
decided by the LHS (up to -99.8%).
-An expensive LHS shows no regression.
-With two cheap predicates and a randomly distributed 50% LHS decision,
the new branch is mispredicted and evaluation is up to ~3 ns/row slower;
with sorted data the same case is ~8-15% faster.

Change-Id: I245793e76d5bd8ce0564c9b35c9c6c939b357c7c
---
M be/src/exprs/compound-predicates.cc
M testdata/workloads/functional-query/queries/QueryTest/exprs.test
2 files changed, 86 insertions(+), 116 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/27/25627/1
--
To view, visit https://gerrit.cloudera.org/25627
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I245793e76d5bd8ce0564c9b35c9c6c939b357c7c
Gerrit-Change-Number: 25627
Gerrit-PatchSet: 1
Gerrit-Owner: Balazs Hevele <[email protected]>

Reply via email to