Skip to content

Commit 206e409

Browse files
committed
Merge pull request amplab#4 from shivaram/master
Set spark mem using slave memory
2 parents 9541a51 + 2e1919d commit 206e409

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

deploy_templates.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@
1111
# ZooKeeper URL, etc as read from the environment.
1212

1313
# Find system memory in KB and compute Spark's default limit from that
14-
system_ram_kb = int(
15-
os.popen("cat /proc/meminfo | grep MemTotal | awk '{print $2}'")
16-
.read().strip())
14+
mem_command = "cat /proc/meminfo | grep MemTotal | awk '{print $2}'"
15+
16+
master_ram_kb = int(
17+
os.popen(mem_command).read().strip())
18+
# This is the master's memory. Try to find slave's memory as well
19+
first_slave = os.popen("cat /root/spark-ec2/slaves | head -1").read().strip()
20+
21+
slave_mem_command = "ssh -t -o StrictHostKeyChecking=no %s %s" %\
22+
(first_slave, mem_command)
23+
slave_ram_kb = int(os.popen(slave_mem_command).read().strip())
24+
25+
system_ram_kb = min(slave_ram_kb, master_ram_kb)
26+
1727
system_ram_mb = system_ram_kb / 1024
1828
if system_ram_mb > 20*1024:
1929
# Leave 3 GB for the OS, HDFS and buffer cache

0 commit comments

Comments
 (0)