-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-16131] initialize internal logger lazily in Scala preferred way #13842
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
| } | ||
| log_ | ||
| } | ||
| protected def log: Logger = log_ |
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.
Do we even need log_ separately from log? log can now be the lazy val.
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.
In class DriverEndpoint under CoarseGrainedSchedulerBackend.scala,
log() seems to be overridden[1]
Not sure, what's the logic behind that but if we can remove that, log()
can also be removed from Logging trait.
On Wed, Jun 22, 2016 at 12:48 PM, Sean Owen notifications@github.com
wrote:
In core/src/main/scala/org/apache/spark/internal/Logging.scala
#13842 (comment):@@ -41,13 +44,7 @@ private[spark] trait Logging {
}// Method to get or create the logger for this object
- protected def log: Logger = {
- if (log_ == null) {
initializeLogIfNecessary(false)log_ = LoggerFactory.getLogger(logName)- }
- log_
- }
- protected def log: Logger = log_
Do we even need log_ separately from log? log can now be the lazy val.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/apache/spark/pull/13842/files/88ffc87c670deb675f443891a4b2e3315467098e#r68046045,
or mute the thread
https://github.com/notifications/unsubscribe/AACdKruY8xLoqhQEkqS167NIyEM-v4Qtks5qOS8lgaJpZM4I7vOl
.
Cheers,
Praj
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.
Good point. I think that can be removed. I don't see the point of it, as neither it nor its subclass even logs anything directly?
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.
Fixed via
infynyxx@986e61f
On Wed, Jun 22, 2016 at 2:17 PM, Sean Owen notifications@github.com wrote:
In core/src/main/scala/org/apache/spark/internal/Logging.scala
#13842 (comment):@@ -41,13 +44,7 @@ private[spark] trait Logging {
}// Method to get or create the logger for this object
- protected def log: Logger = {
- if (log_ == null) {
initializeLogIfNecessary(false)log_ = LoggerFactory.getLogger(logName)- }
- log_
- }
- protected def log: Logger = log_
Good point. I think that can be removed. I don't see the point of it, as
neither it nor its subclass even logs anything directly?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/apache/spark/pull/13842/files/88ffc87c670deb675f443891a4b2e3315467098e#r68060626,
or mute the thread
https://github.com/notifications/unsubscribe/AACdKnkKjiFYLhaEMT3wJslNc4olwNSKks5qOUPtgaJpZM4I7vOl
.
Cheers,
Praj
| // Make the log field transient so that objects with Logging can | ||
| // be serialized and used on another machine | ||
| @transient private var log_ : Logger = null | ||
| @transient lazy val log : Logger = { |
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 think this will fail style checks because of the space before the colon
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.
Yup, my bad. Fixed via
infynyxx@18ae8c5
On Wed, Jun 22, 2016 at 3:15 PM, Sean Owen notifications@github.com wrote:
In core/src/main/scala/org/apache/spark/internal/Logging.scala
#13842 (comment):@@ -32,23 +32,17 @@ private[spark] trait Logging {
// Make the log field transient so that objects with Logging can
// be serialized and used on another machine
- @transient private var log_ : Logger = null
- @transient lazy val log : Logger = {
I think this will fail style checks because of the space before the colon
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/apache/spark/pull/13842/files/986e61f96ece6d7f71ff760384cc7553fe3828f4#r68072052,
or mute the thread
https://github.com/notifications/unsubscribe/AACdKtAjTKSCyAI2oyyH7fFUatd4xsCmks5qOVGUgaJpZM4I7vOl
.
Cheers,
Praj
|
Jenkins test this please |
|
Test build #61040 has finished for PR 13842 at commit
|
|
Jenkins retest this please |
|
Test build #61047 has finished for PR 13842 at commit
|
| // Make the log field transient so that objects with Logging can | ||
| // be serialized and used on another machine | ||
| @transient private var log_ : Logger = null | ||
| @transient lazy val log: Logger = { |
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 think lazy will add a volatile flag to log and prevents some JIT optimizations?
|
So the pros is only calling |
|
Well, it simplifies the code too and avoids a method call. The current variable really ought to be volatile but isn't, so I don't know if that's a downside. I think the performance issue is negligible, since the cost of dereferencing a volatile variable is nothing compared to the time to construct and log the message to disk. It's really minor but I think there are only upsides here. |
|
I was thinking about So 👍 |
|
retest this please |
|
Test build #61065 has finished for PR 13842 at commit
|
|
Thanks. Merging to master and 2.0! |
## What changes were proposed in this pull request? Initialize logger instance lazily in Scala preferred way ## How was this patch tested? By running `./build/mvn clean test` locally Author: Prajwal Tuladhar <praj@infynyxx.com> Closes #13842 from infynyxx/spark_internal_logger. (cherry picked from commit 044971e) Signed-off-by: Shixiong Zhu <shixiong@databricks.com>
What changes were proposed in this pull request?
Initialize logger instance lazily in Scala preferred way
How was this patch tested?
By running
./build/mvn clean testlocally