From: Peter Amstutz Date: Thu, 19 Mar 2015 14:52:42 +0000 (-0400) Subject: 5425: Set memory limit on container as a fraction of total system memory X-Git-Tag: 1.1.0~1725^2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/c96d48a6a5c06a36fb3931c1c9650131e21d79c5 5425: Set memory limit on container as a fraction of total system memory allocated to task each when invoking Docker. --- diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job index b74d7af427..ea9a98717b 100755 --- a/sdk/cli/bin/crunch-job +++ b/sdk/cli/bin/crunch-job @@ -719,13 +719,15 @@ for (my $todo_ptr = 0; $todo_ptr <= $#jobstep_todo; $todo_ptr ++) my $command = "if [ -e $ENV{TASK_WORK} ]; then rm -rf $ENV{TASK_WORK}; fi; " ."mkdir -p $ENV{CRUNCH_TMP} $ENV{JOB_WORK} $ENV{TASK_WORK} $ENV{TASK_KEEPMOUNT} " - ."&& cd $ENV{CRUNCH_TMP} "; + ."&& cd $ENV{CRUNCH_TMP} " + ."&& MEM=\$(cat /proc/meminfo | grep MemTotal | sed 's/\\s\\s*/ /g' |cut -d' ' -f2) " + ."&& MEMLIMIT=\$(( (\$MEM * 95) / ($ENV{CRUNCH_NODE_SLOTS} * 100) )) "; $command .= "&& exec arv-mount --by-id --allow-other $ENV{TASK_KEEPMOUNT} --exec "; if ($docker_hash) { my $cidfile = "$ENV{CRUNCH_TMP}/$Jobstep->{arvados_task}->{uuid}-$Jobstep->{failures}.cid"; $command .= "crunchstat -cgroup-root=/sys/fs/cgroup -cgroup-parent=docker -cgroup-cid=$cidfile -poll=10000 "; - $command .= "$docker_bin run --rm=true --attach=stdout --attach=stderr --attach=stdin -i --user=crunch --cidfile=$cidfile --sig-proxy "; + $command .= "$docker_bin run --rm=true --attach=stdout --attach=stderr --attach=stdin -i --user=crunch --cidfile=$cidfile --sig-proxy --memory=\${MEMLIMIT}k "; # Dynamically configure the container to use the host system as its # DNS server. Get the host's global addresses from the ip command,