-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-13093][SQL] improve null check in nullSafeCodeGen for unary, binary and ternary expression #10987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@cloud-fan I'm not sure how much benefits (performance or code size) we can get from this, this make the code hard to understand. |
|
Can you include the before and after of the generated code that illustrates when this is good? |
|
after: `Substring` with a nullable `pos`, other children are not nullable: before: after: I agree that this PR makes the code a little harder to read, but not that bad, the style of `ctx.genNullCheck` is kind of similar to if block :) |
|
I think this is quite useful, but probably pretty major for performance too if we do it right. The main thing is we should make the code readable. |
|
Could the compiler remove the branch? |
|
Test build #50406 has finished for PR 10987 at commit
|
|
JIT can - after 10000 runs on each partition ... |
|
Since Janino 2.0.9 (September 5, 2004), it has "Optimized compilation of constantly-false IF statements" So it does not need JIT to remove them, the generated bytecode should still be the same. |
|
Does "constantly-false IF" also includes |
|
@cloud-fan The answer is yes, here is how Janino compile the IfStatement: |
|
hmmm, so the benefit is quite small here, let me see if I can improve the code readability, or I agree this PR doesn't worth. |
|
Test build #50467 has finished for PR 10987 at commit
|
|
Test build #50469 has finished for PR 10987 at commit
|
|
LGTM |
|
Merging into master, thanks! |
The current implementation is sub-optimal:
Unhex, we can still remove null check for children if they are not nullable.This PR improves this by making the null check elimination more fine-grained.