Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.stream.Collectors;

import scala.reflect.ClassTag$;
import scala.reflect.ManifestFactory$;
Expand Down Expand Up @@ -324,27 +321,7 @@ public List<AddBlockEvent> buildBlockEvents(List<ShuffleBlockInfo> shuffleBlockI

@Override
public long spill(long size, MemoryConsumer trigger) {
List<AddBlockEvent> events = buildBlockEvents(clear());
List<CompletableFuture<Long>> futures = events.stream().map(x -> spillFunc.apply(x)).collect(Collectors.toList());
CompletableFuture<Void> allOfFutures =
CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()]));
try {
allOfFutures.get(memorySpillTimeoutSec, TimeUnit.SECONDS);
} catch (TimeoutException timeoutException) {
// A best effort strategy to wait.
// If timeout exception occurs, the underlying tasks won't be cancelled.
} finally {
long releasedSize = futures.stream().filter(x -> x.isDone()).mapToLong(x -> {
try {
return x.get();
} catch (Exception e) {
return 0;
}
}).sum();
LOG.info("[taskId: {}] Spill triggered by memory consumer of {}, released memory size: {}",
taskId, trigger.getClass().getSimpleName(), releasedSize);
return releasedSize;
}
return 0L;
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ public void buildBlockEventsTest() {
assertEquals(3, events.size());
}

@Test
public void spillTest() {
SparkConf conf = getConf();
conf.set("spark.rss.client.send.size.limit", "1000");
Expand Down