Skip to content
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-19956][Core]Optimize a location order of blocks with topology information #17300

Closed
wants to merge 4 commits into from

Conversation

ConeyLiu
Copy link
Contributor

What changes were proposed in this pull request?

When call the method getLocations of BlockManager, we only compare the data block host. Random selection for non-local data blocks, this may cause the selected data block to be in a different rack. So in this patch to increase the sort of the rack.

How was this patch tested?

New test case.

Please review http://spark.apache.org/contributing.html before opening a pull request.

@jerryshao
Copy link
Contributor

The fix LGTM, I think it is nice to have such topology priority. CC @mridulm .

val getLocations = PrivateMethod[Seq[BlockManagerId]]('getLocations)
val locations = blockManager invokePrivate getLocations(BroadcastBlockId(0))
assert(locations.map(_.host).toSet
=== Set(localHost, localHost, otherHost, otherHost, otherHost))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove toSet and make Set as Seq ?
Making it a Set sort of looses the point of this change (ordering is lost).
Same for topology info below below.

@@ -555,12 +555,15 @@ private[spark] class BlockManager(

/**
* Return a list of locations for the given block, prioritizing the local machine since
* multiple block managers can share the same host.
* multiple block managers can share the same host, then try to get the same rack data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "then try to get the same rack data" -> "followed by hosts on the same rack" ?

@ConeyLiu
Copy link
Contributor Author

Hi, @jerryshao @mridulm Thanks for your review, I have updated the code.

@@ -497,7 +497,30 @@ class BlockManagerSuite extends SparkFunSuite with Matchers with BeforeAndAfterE
val blockManager = makeBlockManager(128, "exec", bmMaster)
val getLocations = PrivateMethod[Seq[BlockManagerId]]('getLocations)
val locations = blockManager invokePrivate getLocations(BroadcastBlockId(0))
assert(locations.map(_.host).toSet === Set(localHost, localHost, otherHost))
assert(locations.map(_.host) === Seq(localHost, localHost, otherHost))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should also be Seq.

Copy link
Contributor

@mridulm mridulm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, will keep it open in case there are other comments.
+CC @jerryshao , @ConeyLiu

@ConeyLiu
Copy link
Contributor Author

Ok, thanks a lot.

@ConeyLiu
Copy link
Contributor Author

ConeyLiu commented May 4, 2017

Hi, @cloud-fan @zsxwing Can you take a look? Thanks a lot.

@cloud-fan
Copy link
Contributor

retest this please

@cloud-fan
Copy link
Contributor

LGTM

@SparkQA
Copy link

SparkQA commented May 4, 2017

Test build #76453 has finished for PR 17300 at commit 56f5231.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@ConeyLiu
Copy link
Contributor Author

ConeyLiu commented May 5, 2017

retest this please

@mridulm
Copy link
Contributor

mridulm commented May 5, 2017

Will merge when tests pass.

@cloud-fan
Copy link
Contributor

retest this please

*/
private def getLocations(blockId: BlockId): Seq[BlockManagerId] = {
val locs = Random.shuffle(master.getLocations(blockId))
val (preferredLocs, otherLocs) = locs.partition { loc => blockManagerId.host == loc.host }
preferredLocs ++ otherLocs
val (sameRackLocs, differentRackLocs) = otherLocs.partition {
loc => blockManagerId.topologyInfo == loc.topologyInfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If blockManagerId.topologyInfo is None, we will prefer the locations with empty topologyInfo. It is slightly different with what the shuffling wants to do here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified, thanks a lot for the good advice.

@ConeyLiu
Copy link
Contributor Author

ConeyLiu commented May 5, 2017

Thanks both of you for review, I have addressed the comments and modified the test case. Please help calling jenkins for test, because I can't trigger that. Thanks again.

Also passed in local test.

@SparkQA
Copy link

SparkQA commented May 5, 2017

Test build #76473 has finished for PR 17300 at commit 56f5231.

  • This patch fails from timeout after a configured wait of `250m`.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mridulm
Copy link
Contributor

mridulm commented May 5, 2017

retest this please

1 similar comment
@gatorsmile
Copy link
Member

retest this please

@mridulm
Copy link
Contributor

mridulm commented May 5, 2017

That is weird, jenkins should have restarted build when I commented ...

@SparkQA
Copy link

SparkQA commented May 5, 2017

Test build #76500 has finished for PR 17300 at commit a3e979f.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member

retest this please

@SparkQA
Copy link

SparkQA commented May 5, 2017

Test build #76502 has finished for PR 17300 at commit a3e979f.

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

@viirya
Copy link
Member

viirya commented May 6, 2017

LGTM

@ConeyLiu
Copy link
Contributor Author

ConeyLiu commented May 6, 2017

Thanks for your review.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@asfgit asfgit closed this in 1552665 May 8, 2017
@mridulm
Copy link
Contributor

mridulm commented May 8, 2017

Thanks for merging @cloud-fan, this PR kept dropping form my list ...

@ConeyLiu
Copy link
Contributor Author

ConeyLiu commented May 8, 2017

Thanks @cloud-fan @mridulm @gatorsmile

@ConeyLiu ConeyLiu deleted the blockmanager branch May 8, 2017 11:47
liyichao pushed a commit to liyichao/spark that referenced this pull request May 24, 2017
… information

## What changes were proposed in this pull request?

When call the method getLocations of BlockManager, we only compare the data block host. Random selection for non-local data blocks, this may cause the selected data block to be in a different rack. So in this patch to increase the sort of the rack.

## How was this patch tested?

New test case.

Please review http://spark.apache.org/contributing.html before opening a pull request.

Author: Xianyang Liu <xianyang.liu@intel.com>

Closes apache#17300 from ConeyLiu/blockmanager.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants