[SPARK-15795] [SQL] Enable more optimizations in whole stage codegen when isNull is a compile-time constant#13539
[SPARK-15795] [SQL] Enable more optimizations in whole stage codegen when isNull is a compile-time constant#13539inouehrs wants to merge 4 commits intoapache:masterfrom
Conversation
|
test this please |
|
@rxin could you please review this pull request (or please suggest someone I should ask for the review)? |
|
ok to test |
|
This PR seems kind of hacky to me. The optimization in I think we should think about it more, and come up with a holistic solution, i.e. find out all the patterns that represent a foldable value. |
|
cc @davies |
|
Test build #60412 has finished for PR 13539 at commit
|
|
As @cloud-fan said, the implementation is hacky, the improvements is not not obvious (I believe JIT compile do these very well, correct me if I'm wrong), I'd like not do this. There are millions ways to improve the readability of the generated code, but since it's not designed to read by human, so we should not trade in readability of the Scala code for generated code. |
|
@cloud-fan @davies Thank you so much for the comments. (BTW, my original motivation is to eliminate zeroOutNullBytes from the inner-most loop for better optimization in Java JIT compiler. It seems that zeroOutNullBytes affected the performance by few percents for simple map operation.) |
What changes were proposed in this pull request?
Whole stage codegen often creates
isNullvariable initialized with constant false, likeboolean mapelements_isNull = false || false;If there is no further assignment for this
isNullvariable, whole stage codegen can do more optimizations by assumingisNullas a compile-time constant.In the example below, which is generated for a dataset map operation,
mapelements_isNulldefined at line 115 can be assumed by a compile-time constant (false).By assuming this as a constant, the whole stage codegen eliminates
zeroOutNullBytesat line 119 and an if-statement at line 121.In addition to the benefits of improved readability of generated code, eliminating
zeroOutNullByteswill give performance advantage since it is difficult to remove for Java JIT compiler.without this patch
with this patch
How was this patch tested?
by unit tests