Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/9344#discussion_r43826411
--- Diff: core/src/main/java/org/apache/spark/memory/TaskMemoryManager.java
---
@@ -127,23 +127,30 @@ public TaskMemoryManager(MemoryManager memoryManager,
long taskAttemptId) {
*
* @return number of bytes successfully granted (<= N).
*/
- public long acquireExecutionMemory(long required, MemoryConsumer
consumer) {
+ public long acquireExecutionMemory(
+ long required,
+ MemoryMode mode,
+ MemoryConsumer consumer) {
assert(required >= 0);
+ // If we are allocating Tungsten pages off-heap and receive a request
to allocate on-heap
+ // memory here, then it may not make sense to spill since that would
only end up freeing
+ // off-heap memory. This is subject to change, though, so it may be
risky to make this
+ // optimization now in case we forget to undo it late when making
changes.
synchronized (this) {
- long got = memoryManager.acquireExecutionMemory(required,
taskAttemptId);
+ long got = memoryManager.acquireExecutionMemory(required,
taskAttemptId, mode);
- // try to release memory from other consumers first, then we can
reduce the frequency of
+ // Try to release memory from other consumers first, then we can
reduce the frequency of
// spilling, avoid to have too many spilled files.
if (got < required) {
// Call spill() on other consumers to release memory
for (MemoryConsumer c: consumers) {
- if (c != null && c != consumer && c.getUsed() > 0) {
+ if (c != consumer && c.getMemoryUsed(mode) > 0) {
--- End diff --
Because we'd end up storing `null` into the consumers map when allocating
memory that was not requested by a particular consumer.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]