Jelajahi Sumber

Edit configure_mlx.sh for calculate dinamically the value for iogpu.wired_limit_mb and iogpu.wired_lwm_mb. The script limit wired_limit_mb to 80% and wired_lwm_mb to 60%, but this threshold are variables.

Giuseppe Gambino 5 bulan lalu
induk
melakukan
b0d7c34efa
1 mengubah file dengan 23 tambahan dan 3 penghapusan
  1. 23 3
      configure_mlx.sh

+ 23 - 3
configure_mlx.sh

@@ -1,3 +1,23 @@
-# this needs to be dynamic
-# sudo sysctl iogpu.wired_lwm_mb=400000
-# sudo sysctl iogpu.wired_limit_mb=180000
+#!/bin/bash
+
+# Get the total memory in MB
+TOTAL_MEM_MB=$(($(sysctl -n hw.memsize) / 1024 / 1024))
+
+# Calculate the maximum limit as 80% of the total memory
+WIRED_LIMIT_MB=$(($TOTAL_MEM_MB * 80 / 100))
+
+# Calculate the lower bound as 60%-80% of the maximum limit
+WIRED_LWM_MIN=$(($WIRED_LIMIT_MB * 60 / 100))
+WIRED_LWM_MAX=$(($WIRED_LIMIT_MB * 80 / 100))
+
+# Choose a mid-range value for wired_lwm_mb
+WIRED_LWM_MB=$(($WIRED_LWM_MIN + ($WIRED_LWM_MAX - $WIRED_LWM_MIN) / 2))
+
+# Display the calculated values
+echo "Total memory: $TOTAL_MEM_MB MB"
+echo "Maximum limit (iogpu.wired_limit_mb): $WIRED_LIMIT_MB MB"
+echo "Lower bound (iogpu.wired_lwm_mb): $WIRED_LWM_MB MB"
+
+# Apply the values with sysctl
+sudo sysctl -w iogpu.wired_limit_mb=$WIRED_LIMIT_MB
+sudo sysctl -w iogpu.wired_lwm_mb=$WIRED_LWM_MB