Skip to content

Commit

Permalink
api: make nproc wrapper function more conservative
Browse files Browse the repository at this point in the history
require a worst case of 500MB of ram per thread instead of the previous 250MB per thread. compilation errors have been observed with the previous levels on multiple applications.
  • Loading branch information
theofficialgman committed Jun 7, 2024
1 parent 51286a8 commit d086968
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions api
Original file line number Diff line number Diff line change
Expand Up @@ -3650,17 +3650,21 @@ nproc() { #Reduce the number of compile threads on low-RAM systems
#Estimation of how much memory is available for starting new applications, without swapping.
local available="$(free | grep 'Mem:' | awk '{print $7}')"

if [ "$available" -gt $((1000*1024)) ] || [ "$GITHUB_ACTIONS" == "true" ];then
#available memory > 1000MB, use normal number of threads
if [ "$available" -gt $((2000*1024)) ] || [ "$GITHUB_ACTIONS" == "true" ];then
#available memory > 2000MB, use normal number of threads
command nproc
elif [ "$available" -gt $((500*1024)) ];then
#500MB < available memory <= 1000MB, use 2 threads
elif [ "$available" -gt $((1500*1024)) ];then
#1500MB < available memory <= 2000MB, use 3 threads
echo 3
warning "Your system has less than 2000MB of available RAM, so this will compile with only 3 threads."
elif [ "$available" -gt $((1000*1024)) ];then
#1000MB < available memory <= 1500MB, use 2 threads
echo 2
warning "Your system has less than 1000MB of available RAM, so this will compile with only 2 threads."
warning "Your system has less than 1500MB of available RAM, so this will compile with only 2 threads."
else
#available memory <= 500MB, use 1 thread
#available memory <= 1000MB, use 1 thread
echo 1
warning "Your system has less than 500MB of available RAM, so this will compile with only 1 thread."
warning "Your system has less than 1000MB of available RAM, so this will compile with only 1 thread."
fi
}
#end of command interceptors
Expand Down

0 comments on commit d086968

Please sign in to comment.