Skip to content

Commit c9d3002

Browse files
committed
more agressively limit memory in the compute/filesystem containers on compute server to leave room for system processes
1 parent 3f18da0 commit c9d3002

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/packages/server/compute/cloud/startup-script.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,15 @@ docker rm filesystem >/dev/null 2>&1
382382
383383
setState filesystem run '' 45 25
384384
385-
export TOTAL_RAM=$(free -g |grep Mem: | awk '{print $2}')
385+
# Get the total RAM
386+
total_ram=$(free -g | grep Mem: | awk '{print $2}')
387+
388+
# Compute TOTAL_RAM as MAX(1, total_ram - 1)
389+
export TOTAL_RAM=$(($total_ram - 1))
390+
if [ "$TOTAL_RAM" -lt 1 ]; then
391+
# Obviously 0 wouldn't work below.
392+
export TOTAL_RAM=1
393+
fi
386394
387395
mkdir -p /ephemeral
388396
chown 2001:2001 /ephemeral
@@ -464,7 +472,12 @@ docker start compute >/dev/null 2>&1
464472
465473
if [ $? -ne 0 ]; then
466474
setState compute run '' 20 25
467-
export TOTAL_RAM=$(free -g |grep Mem: | awk '{print $2}')
475+
total_ram=$(free -g | grep Mem: | awk '{print $2}')
476+
export TOTAL_RAM=$(($total_ram - 1))
477+
if [ "$TOTAL_RAM" -lt 1 ]; then
478+
# Obviously 0 wouldn't work below.
479+
export TOTAL_RAM=1
480+
fi
468481
mkdir -p /ephemeral
469482
chown 2001:2001 /ephemeral
470483
docker run -d ${gpu ? GPU_FLAGS : ""} \

0 commit comments

Comments
 (0)