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-6050] [yarn] Relax matching of vcore count in received containers. #4818
Conversation
Some YARN configurations return a resource structure for allocated containers that does not match the requested resource. That means Spark would always ignore those containers. So add an option to relax the matching of resources, so that users can still run Spark apps in those situations.
Tested:
I chose to leave the default value as "false" because it seems more correct to be strict when matching, but can change it if others feel that's more appropriate. |
This is specific to vcores and not mem iirc. On Friday, February 27, 2015, Marcelo Vanzin notifications@github.com
|
We don't really lose anything, as far as I can tell. That information is only used to make sure that the allocated containers match those that were requested, not to do any other scheduling within Spark. |
Test FAILed. |
Jenkins, retest this please. |
Test build #28090 has started for PR 4818 at commit
|
// the request; for example, capacity scheduler + DefaultResourceCalculator. Allow users in | ||
// those situations to disable resource matching. | ||
val matchingResource = | ||
if (sparkConf.getBoolean("spark.yarn.container.matchAnyResource", false)) { |
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.
seems like the config is named backwards? If I want to match any then I want to use allocatedContainer.getResource.
Perhaps matchExactResource or keep the name and switch what you get. I would expect to match any by default so its backwards compatible for now.
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.
Also as @mridulm mentioned we are basically just matching what we got back which disables all checks. Before we were checking that memory was atleast big enough.
private def isResourceConstraintSatisfied(container: Container): Boolean = {
container.getResource.getMemory >= (executorMemory + memoryOverhead)
}
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.
Huh, no, if you want to match any you want to use the resource
field, not the value returned by yarn (allocatedContainer.getResource
). That means the comparison will effectively be resource == resource
which will always be true.
I can change the config name if you think that would be clearer.
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.
re: memory, can yarn really allocate a container with less resources than you asked for?
The resource
in this class is pretty much static during the Spark app's lifetime.
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.
Sorry I'm still not seeing it. resource is:
Resource.newInstance(executorMemory + memoryOverhead, executorCores)
which is going to be executorCores passed in, which would be for instance 8 if I request 8.
That resource is then passed to amClient.getMatchingRequests which is going to find requests that have 8 vcores, which isn't what we want because the RM without cpu scheduling returns ones with 1.
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.
Take a look at the latest version to see if it's any clearer.
But the gist is that amClient.getMatchingResources()
is matching the resources you asked for (which is resource
) against the parameter you're passing. What the option controls is whether you're passing resource
also as the resource to match against - so basically, the exact same structure that is already in the outstanding list of requests.
So I think you're reading the condition backwards. Or something.
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.
Oh, sorry I see now. I was reading it backwards and thinking it was matching what was actually allocated.
So I guess the question is whether we want the default of this to be true so that its backwards compatible. Otherwise the behavior changes for anyone running now that upgrades.
Test build #28095 has started for PR 4818 at commit
|
Test build #28090 has finished for PR 4818 at commit
|
Test PASSed. |
Looks good to me - pending addressing Tom's comment about what the default should be. |
No strong opinion from me on the default. Whatever people prefer. |
Test build #28095 has finished for PR 4818 at commit
|
Test PASSed. |
It seems reasonable to me to have the default of "false" and make a comment in the release notes. No strong feelings here though. It depends a lot how many users are hit by this issue. |
// situations to disable matching of the core count. | ||
val matchingResource = | ||
if (sparkConf.getBoolean("spark.yarn.container.disableCpuMatching", false)) { | ||
Resource.newInstance(allocatedContainer.getResource().getMemory(), |
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.
Nit: take out parens for consistency.
My opinion is that we should make the default true, as the vanilla YARN default of |
@sryza When cpu scheduling is enabled (ref @tgravescs comment here and in jira) it must be validated. It is a current implementation detail of YARN that it tries to ensure that response contains resource with adequate cpu and memory (or cpu scheduling is disabled) - but this could easily change in future. |
I wouldn't really agree that this is a YARN implementation detail. This is of course somewhat subjective given that YARN doesn't really document this behavior, but, speaking with my YARN committer hat on, I'd consider a change that makes YARN return smaller containers than requested when CPU scheduling is on a break in compatibility. Not strongly opposed to adding a config, but, if we do, I think it's better for the default to optimize for ease of use over the remote possibility that a future version of YARN might change behavior in this way. Also, whatever behavior we decide on, it would be good (and should be straightforward) to add a test for it in |
AFAIK this is not documented or part of the YARN interfaces/public contract : I would prefer that spark depended on defined interfaces which are reasonably stable. |
I think having the default true would be better so that its backwards compatible. As @sryza mentioned YARN shouldn't really be giving you containers smaller then you requested anyway. |
@vanzin okay so maybe set this to true then? I don't have any opinion, but would love to get this in as it's one of the only release blockers. |
I'll just remove the option then, since it doesn't seem very useful to have an option to enable more strict matching given the discussion. |
Test build #28177 has started for PR 4818 at commit
|
Test build #28177 has finished for PR 4818 at commit
|
Test PASSed. |
this looks good to me. +1. |
…ers. Some YARN configurations return a vcore count for allocated containers that does not match the requested resource. That means Spark would always ignore those containers. So relax the the matching of the vcore count to allow the Spark jobs to run. Author: Marcelo Vanzin <vanzin@cloudera.com> Closes #4818 from vanzin/SPARK-6050 and squashes the following commits: 991c803 [Marcelo Vanzin] Remove config option, standardize on legacy behavior (no vcore matching). 8c9c346 [Marcelo Vanzin] Restrict lax matching to vcores only. 3359692 [Marcelo Vanzin] [SPARK-6050] [yarn] Add config option to do lax resource matching. (cherry picked from commit 6b348d9) Signed-off-by: Thomas Graves <tgraves@apache.org>
Some YARN configurations return a vcore count for allocated
containers that does not match the requested resource. That means
Spark would always ignore those containers. So relax the the matching
of the vcore count to allow the Spark jobs to run.