IMPALA-4269: Codegen merging exchange node This change enables codegen for the tuple row comparator used in merging-exchange node.
With this change, merging-exchange operator improves by 40% and 50% respectively for primitive_orderby_bigint and primitive_orderby_all on TPCH-300, speeding up the query by 6% and 11% respectively. Change-Id: I944b8d52ea63ede58e4dc6fbe6e6953756394d41 Reviewed-on: http://gerrit.cloudera.org:8080/4759 Reviewed-by: Tim Armstrong <[email protected]> Tested-by: Internal Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/502220c6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/502220c6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/502220c6 Branch: refs/heads/hadoop-next Commit: 502220c69d483f785632eaf0030babf40be78ff4 Parents: f1f54fe Author: Michael Ho <[email protected]> Authored: Tue Oct 18 22:37:33 2016 -0700 Committer: Internal Jenkins <[email protected]> Committed: Thu Oct 20 04:42:09 2016 +0000 ---------------------------------------------------------------------- be/src/exec/exchange-node.cc | 12 ++++++++++++ be/src/exec/exchange-node.h | 1 + 2 files changed, 13 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/502220c6/be/src/exec/exchange-node.cc ---------------------------------------------------------------------- diff --git a/be/src/exec/exchange-node.cc b/be/src/exec/exchange-node.cc index fac2ff5..13522a7 100644 --- a/be/src/exec/exchange-node.cc +++ b/be/src/exec/exchange-node.cc @@ -85,10 +85,22 @@ Status ExchangeNode::Prepare(RuntimeState* state) { AddExprCtxsToFree(sort_exec_exprs_); less_than_.reset( new TupleRowComparator(sort_exec_exprs_, is_asc_order_, nulls_first_)); + if (!state->codegen_enabled()) { + runtime_profile()->AddCodegenMsg(false, "disabled by query option DISABLE_CODEGEN"); + } } return Status::OK(); } +void ExchangeNode::Codegen(RuntimeState* state) { + DCHECK(state->codegen_enabled()); + if (is_merging_) { + Status codegen_status = less_than_->Codegen(state); + runtime_profile()->AddCodegenMsg(codegen_status.ok(), codegen_status); + } + ExecNode::Codegen(state); +} + Status ExchangeNode::Open(RuntimeState* state) { SCOPED_TIMER(runtime_profile_->total_time_counter()); RETURN_IF_ERROR(ExecNode::Open(state)); http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/502220c6/be/src/exec/exchange-node.h ---------------------------------------------------------------------- diff --git a/be/src/exec/exchange-node.h b/be/src/exec/exchange-node.h index f6face4..6feaff3 100644 --- a/be/src/exec/exchange-node.h +++ b/be/src/exec/exchange-node.h @@ -46,6 +46,7 @@ class ExchangeNode : public ExecNode { virtual Status Init(const TPlanNode& tnode, RuntimeState* state); virtual Status Prepare(RuntimeState* state); + virtual void Codegen(RuntimeState* state); /// Blocks until the first batch is available for consumption via GetNext(). virtual Status Open(RuntimeState* state); virtual Status GetNext(RuntimeState* state, RowBatch* row_batch, bool* eos);
