-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
SPARK-14091 [core] Consider improving performance of SparkContext.get… #11911
Conversation
…CallSite() (rbalamohan)
CallSite( | ||
Option(getLocalProperty(CallSite.SHORT_FORM)).getOrElse(callSite.shortForm), | ||
Option(getLocalProperty(CallSite.LONG_FORM)).getOrElse(callSite.longForm) | ||
Option(getLocalProperty(CallSite.SHORT_FORM)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point though now this calls Utils.getCallSite
twice when neither property is set. That might be OK, but I wonder if you can instead retrieve both property values, and then proceed to call Utils.getCallSite
once if either is null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @srowen . Incorporated the review comments in the latest commit. Please review.
|
||
if (shortForm == null || longForm == null) { | ||
val callSite = Utils.getCallSite() | ||
shortForm = callSite.shortForm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, but now it will overwrite both props if either is null. That's slightly different behavior from before. It may be true that they're always both null or not null; if that's pretty sure then we can leave this. Otherwise you may need = Option(shortForm).getOrElse(callSite.shortForm)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @srowen. In Utils.withDummyCallSite(), both LONG_FORM and SHORT_FORM are explicitly set to "". But I can see that it is possible to explicitly set one of them via setCallSite(shortCallSite).
Incorporated your review comments in latest commit.
Jenkins test this please |
Test build #53932 has finished for PR 11911 at commit
|
Jenkins retest this please |
Test build #53945 has finished for PR 11911 at commit
|
@@ -1745,11 +1745,16 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli | |||
* has overridden the call site using `setCallSite()`, this will return the user's version. | |||
*/ | |||
private[spark] def getCallSite(): CallSite = { | |||
val callSite = Utils.getCallSite() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would making this into a lazy val
have the same performance-improving impact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I tried that and it didn't work, but I must have done something wrong. It seems to:
scala> def foo(): Int = { println("foo"); 42 }
foo: ()Int
scala> def bar(arg: Boolean): Int = { lazy val f = foo(); if (arg) { f } else { 0 } }
bar: (arg: Boolean)Int
scala> bar(true)
foo
res0: Int = 42
scala> bar(false)
res1: Int = 0
So yeah that could be a much cleaner solution.
Thanks @JoshRosen and @srowen . Retested with "lazy val" which has the same perf improvement. Added "lazy val" in latest commit. |
Jenkins retest this please |
Test build #54029 has finished for PR 11911 at commit
|
Jenkins, retest this please. |
Test build #54049 has finished for PR 11911 at commit
|
Jenkins, retest this please. |
Test build #54195 has finished for PR 11911 at commit
|
LGTM. It looks like the eager evaluation was accidentally introduced in 6600786; prior to that patch it used to be lazy. I'm going to merge this into master. Thanks! |
What changes were proposed in this pull request?
Currently SparkContext.getCallSite() makes a call to Utils.getCallSite().
However, in some places utils.withDummyCallSite(sc) is invoked to avoid expensive threaddumps within getCallSite(). But Utils.getCallSite() is evaluated earlier causing threaddumps to be computed.
This can have severe impact on smaller queries (that finish in 10-20 seconds) having large number of RDDs.
Creating this patch for lazy evaluation of getCallSite.
How was this patch tested?
No new test cases are added. Following standalone test was tried out manually. Also, built entire spark binary and tried with few SQL queries in TPC-DS and TPC-H in multi node cluster
(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
(If this patch involves UI changes, please attach a screenshot; otherwise, remove this)
…CallSite() (rbalamohan)