Skip to content

Commit 3ecbfdf

Browse files
committed
MAPREDUCE-6721. mapreduce.reduce.shuffle.memory.limit.percent=0.0 should be legal to enforce shuffle to disk. (Gera Shegalov via ozawa)
This closes #102 (cherry picked from commit 79a7289)
1 parent 856bc4e commit 3ecbfdf

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/MergeManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public MergeManagerImpl(TaskAttemptID reduceId, JobConf jobConf,
178178
final float singleShuffleMemoryLimitPercent =
179179
jobConf.getFloat(MRJobConfig.SHUFFLE_MEMORY_LIMIT_PERCENT,
180180
DEFAULT_SHUFFLE_MEMORY_LIMIT_PERCENT);
181-
if (singleShuffleMemoryLimitPercent <= 0.0f
181+
if (singleShuffleMemoryLimitPercent < 0.0f
182182
|| singleShuffleMemoryLimitPercent > 1.0f) {
183183
throw new IllegalArgumentException("Invalid value for "
184184
+ MRJobConfig.SHUFFLE_MEMORY_LIMIT_PERCENT + ": "

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@
443443
<name>mapreduce.reduce.shuffle.memory.limit.percent</name>
444444
<value>0.25</value>
445445
<description>Expert: Maximum percentage of the in-memory limit that a
446-
single shuffle can consume</description>
446+
single shuffle can consume. Range of valid values is [0.0, 1.0]. If the value
447+
is 0.0 map outputs are shuffled directly to disk.</description>
447448
</property>
448449

449450
<property>

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/task/reduce/TestMergeManager.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.apache.hadoop.mapred.MROutputFiles;
4242
import org.apache.hadoop.mapred.MapOutputFile;
4343
import org.apache.hadoop.mapreduce.MRJobConfig;
44+
import org.apache.hadoop.mapreduce.TaskAttemptID;
4445
import org.apache.hadoop.mapreduce.task.reduce.MergeManagerImpl.CompressAwarePath;
4546
import org.junit.Assert;
4647
import org.junit.Test;
@@ -289,4 +290,21 @@ null, conf, mock(LocalFileSystem.class), null, null, null, null, null,
289290
assertTrue("Large in-memory reduce area unusable: " + maxInMemReduce,
290291
maxInMemReduce > Integer.MAX_VALUE);
291292
}
293+
294+
@Test
295+
public void testZeroShuffleMemoryLimitPercent() throws Exception {
296+
final JobConf jobConf = new JobConf();
297+
jobConf.setFloat(MRJobConfig.SHUFFLE_MEMORY_LIMIT_PERCENT, 0.0f);
298+
final MergeManager<Text, Text> mgr =
299+
new MergeManagerImpl<>(null, jobConf, mock(LocalFileSystem.class),
300+
null, null, null, null, null, null, null, null, null, null,
301+
new MROutputFiles());
302+
final long mapOutputSize = 10;
303+
final int fetcher = 1;
304+
final MapOutput<Text, Text> mapOutput = mgr.reserve(
305+
TaskAttemptID.forName("attempt_0_1_m_1_1"),
306+
mapOutputSize, fetcher);
307+
assertEquals("Tiny map outputs should be shuffled to disk", "DISK",
308+
mapOutput.getDescription());
309+
}
292310
}

0 commit comments

Comments
 (0)