The problem with GCC is the amount of memory it takes to compile the DFAs. What I've done is set up a script to check /proc/io_status and when io_tokens falls below a certain level I killall -STOP the gcc processes on the system. When the level rises again, I killall -CONT the processes. It takes longer because of all the swapping but the system is usually responsive..
Code:
#!/usr/bin/ruby
###############
def io_status (token=nil)
hash = {}
File.open("/proc/io_status","r").each do |line|
line.split.each do |item|
key,value = item.split("=")
hash.update( { key=>value } )
end
end
return hash if not token
return hash[token]
end
print Time.new, " * ", io_status('io_tokens'), "\n"
system('killall -STOP cc1')
system('killall -STOP cc1plus')
system('killall -STOP xgcc')
while true
while io_status('io_tokens').to_i < 160000 ; sleep 6 ; end
print Time.new, " + ", io_status('io_tokens'), "\n"
system('killall -CONT cc1')
system('killall -CONT cc1plus')
system('killall -CONT xgcc')
while io_status('io_tokens').to_i > 80000 ; sleep 6 ; end
print Time.new, " - ", io_status('io_tokens'), "\n"
system('killall -STOP cc1')
system('killall -STOP cc1plus')
system('killall -STOP xgcc')
end