Skip to content

Commit d996479

Browse files
committed
YARN-4599. Set OOM control for memory cgroups. (Miklos Szegedi via Haibo Chen)
1 parent f09dc73 commit d996479

File tree

22 files changed

+2391
-39
lines changed

22 files changed

+2391
-39
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
target
1818
build
1919
dependency-reduced-pom.xml
20+
make-build-debug
2021

2122
# Filesystem contract test options and credentials
2223
auth-keys.xml

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,25 @@ public static boolean isAclEnabled(Configuration conf) {
14401440
NM_PREFIX + "vmem-pmem-ratio";
14411441
public static final float DEFAULT_NM_VMEM_PMEM_RATIO = 2.1f;
14421442

1443+
/** Specifies whether to do memory check on overall usage. */
1444+
public static final String NM_ELASTIC_MEMORY_CONTROL_ENABLED = NM_PREFIX
1445+
+ "elastic-memory-control.enabled";
1446+
public static final boolean DEFAULT_NM_ELASTIC_MEMORY_CONTROL_ENABLED = false;
1447+
1448+
/** Specifies the OOM handler code. */
1449+
public static final String NM_ELASTIC_MEMORY_CONTROL_OOM_HANDLER = NM_PREFIX
1450+
+ "elastic-memory-control.oom-handler";
1451+
1452+
/** The path to the OOM listener.*/
1453+
public static final String NM_ELASTIC_MEMORY_CONTROL_OOM_LISTENER_PATH =
1454+
NM_PREFIX + "elastic-memory-control.oom-listener.path";
1455+
1456+
/** Maximum time in seconds to resolve an OOM situation. */
1457+
public static final String NM_ELASTIC_MEMORY_CONTROL_OOM_TIMEOUT_SEC =
1458+
NM_PREFIX + "elastic-memory-control.timeout-sec";
1459+
public static final Integer
1460+
DEFAULT_NM_ELASTIC_MEMORY_CONTROL_OOM_TIMEOUT_SEC = 5;
1461+
14431462
/** Number of Virtual CPU Cores which can be allocated for containers.*/
14441463
public static final String NM_VCORES = NM_PREFIX + "resource.cpu-vcores";
14451464
public static final int DEFAULT_NM_VCORES = 8;
@@ -2006,13 +2025,6 @@ public static boolean isAclEnabled(Configuration conf) {
20062025
/** The path to the Linux container executor.*/
20072026
public static final String NM_LINUX_CONTAINER_EXECUTOR_PATH =
20082027
NM_PREFIX + "linux-container-executor.path";
2009-
2010-
/**
2011-
* The UNIX group that the linux-container-executor should run as.
2012-
* This is intended to be set as part of container-executor.cfg.
2013-
*/
2014-
public static final String NM_LINUX_CONTAINER_GROUP =
2015-
NM_PREFIX + "linux-container-executor.group";
20162028

20172029
/**
20182030
* True if linux-container-executor should limit itself to one user

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@
772772
<property>
773773
<description>Maximum size in bytes for configurations that can be provided
774774
by application to RM for delegation token renewal.
775-
By experiment, it's roughly 128 bytes per key-value pair.
775+
By experiment, its roughly 128 bytes per key-value pair.
776776
The default value 12800 allows roughly 100 configs, may be less.
777777
</description>
778778
<name>yarn.resourcemanager.delegation-token.max-conf-size-bytes</name>
@@ -1859,14 +1859,6 @@
18591859
<value>1000</value>
18601860
</property>
18611861

1862-
<property>
1863-
<description>
1864-
The UNIX group that the linux-container-executor should run as.
1865-
</description>
1866-
<name>yarn.nodemanager.linux-container-executor.group</name>
1867-
<value></value>
1868-
</property>
1869-
18701862
<property>
18711863
<description>T-file compression types used to compress aggregated logs.</description>
18721864
<name>yarn.nodemanager.log-aggregation.compression-type</name>
@@ -2158,7 +2150,7 @@
21582150
<description>
21592151
In the server side it indicates whether timeline service is enabled or not.
21602152
And in the client side, users can enable it to indicate whether client wants
2161-
to use timeline service. If it's enabled in the client side along with
2153+
to use timeline service. If its enabled in the client side along with
21622154
security, then yarn client tries to fetch the delegation tokens for the
21632155
timeline server.
21642156
</description>
@@ -3404,7 +3396,7 @@
34043396
<description>
34053397
Defines the limit of the diagnostics message of an application
34063398
attempt, in kilo characters (character count * 1024).
3407-
When using ZooKeeper to store application state behavior, it's
3399+
When using ZooKeeper to store application state behavior, its
34083400
important to limit the size of the diagnostic messages to
34093401
prevent YARN from overwhelming ZooKeeper. In cases where
34103402
yarn.resourcemanager.state-store.max-completed-applications is set to
@@ -3819,4 +3811,57 @@
38193811
<value>/usr/bin/numactl</value>
38203812
</property>
38213813

3814+
<property>
3815+
<description>
3816+
Enable elastic memory control. This is a Linux only feature.
3817+
When enabled, the node manager adds a listener to receive an
3818+
event, if all the containers exceeded a limit.
3819+
The limit is specified by yarn.nodemanager.resource.memory-mb.
3820+
If this is not set, the limit is set based on the capabilities.
3821+
See yarn.nodemanager.resource.detect-hardware-capabilities
3822+
for details.
3823+
The limit applies to the physical or virtual (rss+swap) memory
3824+
depending on whether yarn.nodemanager.pmem-check-enabled or
3825+
yarn.nodemanager.vmem-check-enabled is set.
3826+
</description>
3827+
<name>yarn.nodemanager.elastic-memory-control.enabled</name>
3828+
<value>false</value>
3829+
</property>
3830+
3831+
<property>
3832+
<description>
3833+
The name of a JVM class. The class must implement the Runnable
3834+
interface. It is called,
3835+
if yarn.nodemanager.elastic-memory-control.enabled
3836+
is set and the system reaches its memory limit.
3837+
When called the handler must preempt a container,
3838+
since all containers are frozen by cgroups.
3839+
Once preempted some memory is released, so that the
3840+
kernel can resume all containers. Because of this the
3841+
handler has to act quickly.
3842+
</description>
3843+
<name>yarn.nodemanager.elastic-memory-control.oom-handler</name>
3844+
<value>org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.DefaultOOMHandler</value>
3845+
</property>
3846+
3847+
<property>
3848+
<description>
3849+
The path to the oom-listener tool. Elastic memory control is only
3850+
supported on Linux. It relies on kernel events. The tool forwards
3851+
these kernel events to the standard input, so that the node manager
3852+
can preempt containers, in and out-of-memory scenario.
3853+
You rarely need to update this setting.
3854+
</description>
3855+
<name>yarn.nodemanager.elastic-memory-control.oom-listener.path</name>
3856+
<value></value>
3857+
</property>
3858+
3859+
<property>
3860+
<description>
3861+
Maximum time to wait for an OOM situation to get resolved before
3862+
bringing down the node.
3863+
</description>
3864+
<name>yarn.nodemanager.elastic-memory-control.timeout-sec</name>
3865+
<value>5</value>
3866+
</property>
38223867
</configuration>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ string(REGEX MATCH . HCD_ONE "${HADOOP_CONF_DIR}")
3030
string(COMPARE EQUAL ${HCD_ONE} / HADOOP_CONF_DIR_IS_ABS)
3131

3232
set (CMAKE_C_STANDARD 99)
33+
set (CMAKE_CXX_STANDARD 11)
3334

3435
include(CheckIncludeFiles)
3536
check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYS_SYSCTL_H)
@@ -113,6 +114,7 @@ include_directories(
113114
${GTEST_SRC_DIR}/include
114115
main/native/container-executor
115116
main/native/container-executor/impl
117+
main/native/oom-listener/impl
116118
)
117119
# add gtest as system library to suppress gcc warnings
118120
include_directories(SYSTEM ${GTEST_SRC_DIR}/include)
@@ -171,3 +173,20 @@ add_executable(cetest
171173
main/native/container-executor/test/utils/test_docker_util.cc)
172174
target_link_libraries(cetest gtest container)
173175
output_directory(cetest test)
176+
177+
# CGroup OOM listener
178+
add_executable(oom-listener
179+
main/native/oom-listener/impl/oom_listener.c
180+
main/native/oom-listener/impl/oom_listener.h
181+
main/native/oom-listener/impl/oom_listener_main.c
182+
)
183+
output_directory(oom-listener target/usr/local/bin)
184+
185+
# CGroup OOM listener test with GTest
186+
add_executable(test-oom-listener
187+
main/native/oom-listener/impl/oom_listener.c
188+
main/native/oom-listener/impl/oom_listener.h
189+
main/native/oom-listener/test/oom_listener_test_main.cc
190+
)
191+
target_link_libraries(test-oom-listener gtest)
192+
output_directory(test-oom-listener test)

0 commit comments

Comments
 (0)