Skip to content

Conversation

@lianhuiwang
Copy link
Contributor

@lianhuiwang lianhuiwang commented May 10, 2016

What changes were proposed in this pull request?

  1. Fix code style
  2. remove volatile of elementsRead method because there is only one thread to use it.
  3. avoid volatile of _elementsRead because Collection increases number of _elementsRead when it insert a element. It is very expensive. So we can avoid it.

After this PR, I will push another PR for branch 1.6.

How was this patch tested?

unit tests


// 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.

@lianhuiwang
Copy link
Contributor Author

cc @davies

if (!isSpilled) {
0L
} else {
_elementsRead = 0
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.

@davies
Copy link
Contributor

davies commented May 10, 2016

Is this really an hot fix (serious bug or breaking tests)?

@lianhuiwang lianhuiwang changed the title [SPARK-4452][Core][HOT-FIX] Fix code style and improve volatile [SPARK-4452][Core] Fix code style and improve volatile for Spillable May 10, 2016
@lianhuiwang lianhuiwang changed the title [SPARK-4452][Core] Fix code style and improve volatile for Spillable [SPARK-15246][Core] Fix code style and improve volatile for SPARK-4452 May 10, 2016
@lianhuiwang
Copy link
Contributor Author

@davies I think it is not an hot fix. So i have updated PR. thanks.

@SparkQA
Copy link

SparkQA commented May 10, 2016

Test build #58203 has finished for PR 13020 at commit 3839557.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@davies
Copy link
Contributor

davies commented May 10, 2016

LGTM

protected def forceSpill(): Boolean

// Number of elements read from input since last spill
@volatile protected def elementsRead: Long = _elementsRead
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.

@rxin
Copy link
Contributor

rxin commented May 11, 2016

Merging in master/2.0. Thanks.

asfgit pushed a commit that referenced this pull request May 11, 2016
## What changes were proposed in this pull request?
1. Fix code style
2. remove volatile of elementsRead method because there is only one thread to use it.
3. avoid volatile of _elementsRead because Collection increases number of  _elementsRead when it insert a element. It is very expensive. So we can avoid it.

After this PR, I will push another PR for branch 1.6.
## How was this patch tested?
unit tests

Author: Lianhui Wang <[email protected]>

Closes #13020 from lianhuiwang/SPARK-4452-hotfix.

(cherry picked from commit 9f0a642)
Signed-off-by: Reynold Xin <[email protected]>
@asfgit asfgit closed this in 9f0a642 May 11, 2016
zzcclp added a commit to zzcclp/spark that referenced this pull request May 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants