Alex Cheema 6 months ago
parent
commit
9a11e27c93
1 changed files with 41 additions and 35 deletions
  1. 41 35
      .github/bootstrap.sh

+ 41 - 35
.github/bootstrap.sh

@@ -169,27 +169,22 @@ log "Configuring runner with labels: $CUSTOM_LABELS"
 # Set optimal performance settings
 # Set optimal performance settings
 log "Configuring system for optimal performance..."
 log "Configuring system for optimal performance..."
 
 
-# Force high performance mode using native macOS tools
-sudo nvram boot-args="gpuswitch=2 amfi_get_out_of_my_way=1 serverperfmode=1"
-sudo pmset force -a ac
-
-# Disable power management and force performance mode
-sudo pmset -a gpuswitch 2  # Force discrete GPU
-sudo pmset -a lowpowermode 0
+# Configure power management settings for maximum performance
+log "Setting power management options..."
+sudo pmset -a displaysleep 0
+sudo pmset -a disksleep 0
+sudo pmset -a sleep 0
 sudo pmset -a hibernatemode 0
 sudo pmset -a hibernatemode 0
-sudo pmset -a standby 0
-sudo pmset -a autopoweroff 0
 sudo pmset -a powernap 0
 sudo pmset -a powernap 0
-sudo pmset -a sleep 0
-sudo pmset -a disksleep 0
-sudo pmset -a powermode 1
-sudo pmset -a lessbright 0
-sudo pmset -a halfdim 0
+sudo pmset -a proximitywake 0
+sudo pmset -a tcpkeepalive 1
+sudo pmset -a ttyskeepawake 1
 sudo pmset -a acwake 0
 sudo pmset -a acwake 0
 sudo pmset -a lidwake 0
 sudo pmset -a lidwake 0
-sudo pmset -a proximitywake 0
+sudo pmset -a lessbright 0
+sudo pmset -a halfdim 0
 
 
-# Create performance mode configuration
+# Create performance mode configuration with supported settings
 sudo tee /Library/Preferences/com.apple.perfmode.plist << EOF
 sudo tee /Library/Preferences/com.apple.perfmode.plist << EOF
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -198,14 +193,12 @@ sudo tee /Library/Preferences/com.apple.perfmode.plist << EOF
     <key>Mode</key>
     <key>Mode</key>
     <string>Performance</string>
     <string>Performance</string>
     <key>PowerMode</key>
     <key>PowerMode</key>
-    <integer>1</integer>
-    <key>GPUSwitch</key>
     <integer>2</integer>
     <integer>2</integer>
 </dict>
 </dict>
 </plist>
 </plist>
 EOF
 EOF
 
 
-# Disable Metal validation and debugging
+# Enhanced Metal and GPU settings using defaults
 defaults write com.apple.CoreML MPSEnableGPUValidation -bool false
 defaults write com.apple.CoreML MPSEnableGPUValidation -bool false
 defaults write com.apple.CoreML MPSEnableMetalValidation -bool false
 defaults write com.apple.CoreML MPSEnableMetalValidation -bool false
 defaults write com.apple.CoreML MPSEnableGPUDebug -bool false
 defaults write com.apple.CoreML MPSEnableGPUDebug -bool false
@@ -216,8 +209,10 @@ defaults write com.apple.Metal MetalCaptureEnabled -bool false
 defaults write com.apple.Metal MTLValidationBehavior -string "Disabled"
 defaults write com.apple.Metal MTLValidationBehavior -string "Disabled"
 defaults write com.apple.Metal EnableMTLDebugLayer -bool false
 defaults write com.apple.Metal EnableMTLDebugLayer -bool false
 defaults write com.apple.Metal MTLDebugLevel -int 0
 defaults write com.apple.Metal MTLDebugLevel -int 0
+defaults write com.apple.Metal PreferIntegratedGPU -bool false
+defaults write com.apple.Metal ForceMaximumPerformance -bool true
 
 
-# Create MPS cache directory with appropriate permissions
+# Create enhanced MPS cache configuration
 sudo mkdir -p /tmp/mps_cache
 sudo mkdir -p /tmp/mps_cache
 sudo chmod 777 /tmp/mps_cache
 sudo chmod 777 /tmp/mps_cache
 
 
@@ -271,13 +266,9 @@ sudo tee /Library/LaunchDaemons/com.github.runner.plist > /dev/null << EOF
         <string>${RUNNER_DIR}</string>
         <string>${RUNNER_DIR}</string>
         <key>ProgramArguments</key>
         <key>ProgramArguments</key>
         <array>
         <array>
-            <string>/usr/bin/taskpolicy</string>
-            <string>-p</string>
-            <string>PERFORMANCE</string>
-            <string>-b</string>
-            <string>PERFORMANCE</string>
-            <string>-t</string>
-            <string>PERFORMANCE</string>
+            <string>/usr/bin/nice</string>
+            <string>-n</string>
+            <string>-20</string>
             <string>${RUNNER_DIR}/run.sh</string>
             <string>${RUNNER_DIR}/run.sh</string>
         </array>
         </array>
         <key>EnvironmentVariables</key>
         <key>EnvironmentVariables</key>
@@ -303,6 +294,10 @@ sudo tee /Library/LaunchDaemons/com.github.runner.plist > /dev/null << EOF
             <string>0</string>
             <string>0</string>
             <key>MLX_FORCE_P_CORES</key>
             <key>MLX_FORCE_P_CORES</key>
             <string>1</string>
             <string>1</string>
+            <key>MLX_METAL_MEMORY_BUDGET</key>
+            <string>0</string>
+            <key>MLX_METAL_PREWARM</key>
+            <string>1</string>
             <!-- Metal Settings -->
             <!-- Metal Settings -->
             <key>METAL_DEBUG_ERROR_MODE</key>
             <key>METAL_DEBUG_ERROR_MODE</key>
             <string>0</string>
             <string>0</string>
@@ -329,30 +324,41 @@ sudo tee /Library/LaunchDaemons/com.github.runner.plist > /dev/null << EOF
             <string>1</string>
             <string>1</string>
             <key>MPS_CACHE_DIRECTORY</key>
             <key>MPS_CACHE_DIRECTORY</key>
             <string>/tmp/mps_cache</string>
             <string>/tmp/mps_cache</string>
+            <key>MPS_MEMORY_BUDGET</key>
+            <string>0</string>
+            <key>MPS_PURGE_ON_LAUNCH</key>
+            <string>0</string>
             <key>DISABLE_METAL_VALIDATION</key>
             <key>DISABLE_METAL_VALIDATION</key>
             <string>1</string>
             <string>1</string>
-            <!-- CPU Affinity -->
+            <!-- CPU Priority -->
             <key>QOS_CLASS_USER_INTERACTIVE</key>
             <key>QOS_CLASS_USER_INTERACTIVE</key>
             <string>1</string>
             <string>1</string>
             <key>PERFORMANCE_MODE</key>
             <key>PERFORMANCE_MODE</key>
             <string>1</string>
             <string>1</string>
         </dict>
         </dict>
-        <key>Nice</key>
-        <integer>-20</integer>
+        <key>RunAtLoad</key>
+        <true/>
+        <key>KeepAlive</key>
+        <true/>
         <key>ProcessType</key>
         <key>ProcessType</key>
         <string>Interactive</string>
         <string>Interactive</string>
         <key>LowPriorityIO</key>
         <key>LowPriorityIO</key>
         <false/>
         <false/>
+        <key>AbandonProcessGroup</key>
+        <false/>
     </dict>
     </dict>
 </plist>
 </plist>
 EOF
 EOF
 
 
-# Load the LaunchDaemons
-sudo launchctl load -w /Library/LaunchDaemons/com.github.runner.cpuaffinity.plist
-sudo launchctl load -w /Library/LaunchDaemons/com.github.runner.plist
+# Set proper permissions for the LaunchDaemon
+sudo chown root:wheel /Library/LaunchDaemons/com.github.runner.plist
+sudo chmod 644 /Library/LaunchDaemons/com.github.runner.plist
+
+# Remove any existing service
+sudo launchctl bootout system/com.github.runner 2>/dev/null || true
 
 
-# Set CPU affinity for the current process
-taskpolicy -p PERFORMANCE -b PERFORMANCE -t PERFORMANCE
+# Load the new service using bootstrap
+sudo launchctl bootstrap system /Library/LaunchDaemons/com.github.runner.plist
 
 
 # Add Runner.Listener permissions (after runner installation)
 # Add Runner.Listener permissions (after runner installation)
 RUNNER_PATH="$RUNNER_DIR/bin/Runner.Listener"
 RUNNER_PATH="$RUNNER_DIR/bin/Runner.Listener"