Skip to content

Commit

Permalink
Merge pull request amplab#4 from shivaram/master
Browse files Browse the repository at this point in the history
Set spark mem using slave memory
  • Loading branch information
mateiz committed Feb 22, 2013
2 parents 9541a51 + 2e1919d commit 206e409
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions deploy_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@
# ZooKeeper URL, etc as read from the environment.

# Find system memory in KB and compute Spark's default limit from that
system_ram_kb = int(
os.popen("cat /proc/meminfo | grep MemTotal | awk '{print $2}'")
.read().strip())
mem_command = "cat /proc/meminfo | grep MemTotal | awk '{print $2}'"

master_ram_kb = int(
os.popen(mem_command).read().strip())
# This is the master's memory. Try to find slave's memory as well
first_slave = os.popen("cat /root/spark-ec2/slaves | head -1").read().strip()

slave_mem_command = "ssh -t -o StrictHostKeyChecking=no %s %s" %\
(first_slave, mem_command)
slave_ram_kb = int(os.popen(slave_mem_command).read().strip())

system_ram_kb = min(slave_ram_kb, master_ram_kb)

system_ram_mb = system_ram_kb / 1024
if system_ram_mb > 20*1024:
# Leave 3 GB for the OS, HDFS and buffer cache
Expand Down

0 comments on commit 206e409

Please sign in to comment.