-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-32872][CORE] Prevent BytesToBytesMap at MAX_CAPACITY from exceeding growth threshold #29744
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 2 commits
c3afb09
de0f9fe
7d76463
ec51e65
f610fbe
680c4cf
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 |
|---|---|---|
|
|
@@ -816,6 +816,10 @@ public boolean append(Object kbase, long koff, int klen, Object vbase, long voff | |
| } catch (SparkOutOfMemoryError oom) { | ||
| canGrowArray = false; | ||
| } | ||
| } else if (numKeys >= growthThreshold && longArray.size() / 2 >= MAX_CAPACITY) { | ||
| // The map cannot grow because doing so would cause it to exceed MAX_CAPACITY. Instead, we | ||
| // prevent the map from accepting any more new elements. | ||
| canGrowArray = false; | ||
|
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. I think we won't exceed The root cause, I think, is once the map reaches This change favors reusing the array for sorting, but it prevents the map accepting new elements more early, half of the array is not used after the map capacity reaches When I was fixing the customer application before, we don't see the OOM even the payload reached
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 agree. Once we reach The code currently does (a). If the number of groups ultimately turns out to be less than It seems to me that it would be better to prevent queries from failing, as (b) does. This does mean we would spill earlier for a narrow range of queries.
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. Regarding the memory setting: I agree that whether or not an OOM will occur is dependent on the memory setting, but I would argue that (1) the user should not be required to tune memory settings to avoid failing queries, and (2) many reasonable settings will cause an OOM. The problem arises when there are between 2^28+1 and 2^29 keys. If we need to spill, |
||
| } | ||
| } | ||
| return true; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.