[object Object]

← back to Exo

more robust configure_mlx.sh

cb40eb23ce7d146793a2d19e6aa9596b46b617a6 · 2024-12-11 15:38:45 +0000 · Alex Cheema

Files touched

Diff

commit cb40eb23ce7d146793a2d19e6aa9596b46b617a6
Author: Alex Cheema <alexcheema123@gmail.com>
Date:   Wed Dec 11 15:38:45 2024 +0000

    more robust configure_mlx.sh
---
 configure_mlx.sh | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/configure_mlx.sh b/configure_mlx.sh
index 8a5b6737..f3469c82 100755
--- a/configure_mlx.sh
+++ b/configure_mlx.sh
@@ -3,10 +3,27 @@
 # Get the total memory in MB
 TOTAL_MEM_MB=$(($(sysctl -n hw.memsize) / 1024 / 1024))
 
-# Set WIRED_LIMIT_MB to 80%
-WIRED_LIMIT_MB=$(($TOTAL_MEM_MB * 80 / 100))
-# Set  WIRED_LWM_MB to 70%
-WIRED_LWM_MB=$(($TOTAL_MEM_MB * 70 / 100))
+# Calculate 80% and TOTAL_MEM_GB-5GB in MB
+EIGHTY_PERCENT=$(($TOTAL_MEM_MB * 80 / 100))
+MINUS_5GB=$((($TOTAL_MEM_MB - 5120)))
+
+# Calculate 70% and TOTAL_MEM_GB-8GB in MB
+SEVENTY_PERCENT=$(($TOTAL_MEM_MB * 70 / 100))
+MINUS_8GB=$((($TOTAL_MEM_MB - 8192)))
+
+# Set WIRED_LIMIT_MB to higher value
+if [ $EIGHTY_PERCENT -gt $MINUS_5GB ]; then
+  WIRED_LIMIT_MB=$EIGHTY_PERCENT
+else
+  WIRED_LIMIT_MB=$MINUS_5GB
+fi
+
+# Set WIRED_LWM_MB to higher value
+if [ $SEVENTY_PERCENT -gt $MINUS_8GB ]; then
+  WIRED_LWM_MB=$SEVENTY_PERCENT
+else
+  WIRED_LWM_MB=$MINUS_8GB
+fi
 
 # Display the calculated values
 echo "Total memory: $TOTAL_MEM_MB MB"

← afe71c01 check gpu usage  ·  back to Exo  ·  bootstrap script tweaks ba96413a →