-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-15246][Core] Fix code style and improve volatile for SPARK-4452 #13020
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ private[spark] abstract class Spillable[C](taskMemoryManager: TaskMemoryManager) | |
| protected def forceSpill(): Boolean | ||
|
|
||
| // Number of elements read from input since last spill | ||
| @volatile protected def elementsRead: Long = _elementsRead | ||
| protected def elementsRead: Long = _elementsRead | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not meaningful to make a method volatile anyway right? the fact that it's not an error makes me think I could be missing something. No objection
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think you understand correctly. we can remove volatile of elementsRead method because there is only one thread to use it. |
||
|
|
||
| // Called by subclasses every time a record is read | ||
| // It's used for checking spilling frequency | ||
|
|
@@ -112,7 +112,6 @@ private[spark] abstract class Spillable[C](taskMemoryManager: TaskMemoryManager) | |
| if (!isSpilled) { | ||
| 0L | ||
| } else { | ||
| _elementsRead = 0 | ||
| val freeMemory = myMemoryThreshold - initialMemoryThreshold | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I delete this code in order to _elementsRead is called by one thread. So we do not need to make _elementsRead volatile. |
||
| _memoryBytesSpilled += freeMemory | ||
| releaseMemory() | ||
|
|
||
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.
can you comment on why the changes are safe/correct?
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.
It has only one thread to use this method. So we can remove volatile.