Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public long getMemoryConsumptionForThisTask() {
/**
* Returns Tungsten memory mode
*/
public MemoryMode getTungstenMemoryMode(){
public MemoryMode getTungstenMemoryMode() {
return tungstenMemoryMode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

@lianhuiwang lianhuiwang May 11, 2016

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -112,7 +112,6 @@ private[spark] abstract class Spillable[C](taskMemoryManager: TaskMemoryManager)
if (!isSpilled) {
0L
} else {
_elementsRead = 0
val freeMemory = myMemoryThreshold - initialMemoryThreshold
Copy link
Contributor Author

@lianhuiwang lianhuiwang May 10, 2016

Choose a reason for hiding this comment

The 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()
Expand Down