impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Armstrong (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-4883: Union Codegen
Date Thu, 30 Mar 2017 22:59:40 GMT
Tim Armstrong has posted comments on this change.

Change subject: IMPALA-4883: Union Codegen

Patch Set 4:


Hmm, I guess the per-row overhead is probably not as significant for the case when we're returning
a bunch of columns. There might be a more pronounced effect if we're just returning a handful
of columns. 

I think we can still squeeze some more cycles out of this with minimal effort, but if we stop
seeing a measurable improvement for a query that returns a smaller number of columns we could
consider stopping then.
File be/src/exec/

Line 28:   while (!dst_batch->AtCapacity() && child_row_idx_ < child_batch_->num_rows())
The remaining optimisation is to pull all references to member variables out of the loop.
I.e. child_row_idx_, child_batch_, child_row_idx_, child_expr_lists_, tuple_desc_->byte_size().
This will reduce the number of loads and stores quite a bit. E.g.

int child_row_idx = child_row_idx_;
int tuple_byte_size = tuple_desc_->byte_size;
while (...) {

child_row_idx_ = child_row_idx;

Currently it will do a load and store to variables like 'child_row_idx_' via the 'this' pointer
on every loop iteration.

The compiler could do that automatically if it could deduce that the values aren't modified
via a different pointer, but I don't think it's deducible in this case because the compiler
has  to generate code that's "correct" in a weird case like 'this' and *tuple_buf pointing
to the same memory.

Line 34:     if (ReachedLimit()) break;
We can avoid checking limits for each row if we check it at the end and truncate the batch
using RowBatch::set_num_rows. E.g. see SortNode::GetNext().

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib4107d27582ff5416172810364a6e76d3d93c439
Gerrit-PatchSet: 4
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Taras Bobrovytsky <>
Gerrit-Reviewer: Michael Ho <>
Gerrit-Reviewer: Taras Bobrovytsky <>
Gerrit-Reviewer: Tim Armstrong <>
Gerrit-HasComments: Yes

View raw message