<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: I use Python to enable load balancing for the 14th generation. in Intel® Distribution for Python*</title>
    <link>https://community.intel.com/t5/Intel-Distribution-for-Python/I-use-Python-to-enable-load-balancing-for-the-14th-generation/m-p/1670941#M2239</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Thank you for sharing your insights and your approach to optimizing CPU performance. We appreciate your interest in enhancing our product. At this time, our focus is on maintaining the current scope and features of our product. However, we will keep your feedback in mind as we continue to evaluate potential updates and improvements. Please feel free to reach out with any other ideas or questions you may have.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Stef&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Feb 2025 07:51:27 GMT</pubDate>
    <dc:creator>StefR_Intel</dc:creator>
    <dc:date>2025-02-28T07:51:27Z</dc:date>
    <item>
      <title>I use Python to enable load balancing for the 14th generation.</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/I-use-Python-to-enable-load-balancing-for-the-14th-generation/m-p/1669905#M2238</link>
      <description>&lt;P&gt;I use the i7-14700F to achieve smooth performance without stuttering and reduce heat generation. Through affinity, I optimize the efficiency of idle cores, maximizing CPU performance while reducing heat. Will Intel consider this for future updates?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-02-25 17 10 19.png" style="width: 654px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/63220iBC759F516A367CC1/image-dimensions/654x342/is-moderation-mode/true?v=v2&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" width="654" height="342" role="button" title="2025-02-25 17 10 19.png" alt="2025-02-25 17 10 19.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Needs to be run as administrator.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;import psutil&lt;BR /&gt;import time&lt;BR /&gt;import threading&lt;/P&gt;&lt;P&gt;class CPUMonitor:&lt;BR /&gt;def __init__(self):&lt;BR /&gt;self.running = threading.Event()&lt;BR /&gt;self.thread = None&lt;BR /&gt;self.monitor_interval = 0 # Set monitoring interval to 0&lt;BR /&gt;self.load_threshold = 30 # Load threshold&lt;BR /&gt;total_cores = psutil.cpu_count(logical=False)&lt;BR /&gt;self.min_cores = total_cores - 3&lt;BR /&gt;self.disabled_cores = set()&lt;BR /&gt;self.kept_cores = set()&lt;BR /&gt;self.start()&lt;/P&gt;&lt;P&gt;def get_cpu_load(self):&lt;BR /&gt;return psutil.cpu_percent(percpu=True)&lt;/P&gt;&lt;P&gt;def set_cpu_affinity(self, cpu_indices):&lt;BR /&gt;success_count = 0&lt;BR /&gt;fail_count = 0&lt;BR /&gt;&lt;BR /&gt;# Directly handle the objects in the process iterator to avoid secondary queries&lt;BR /&gt;for proc in psutil.process_iter(attrs=['pid', 'name']):&lt;BR /&gt;if proc.info['name'].lower() in ['system', 'idle']:&lt;BR /&gt;continue&lt;BR /&gt;try:&lt;BR /&gt;proc.cpu_affinity(cpu_indices)&lt;BR /&gt;success_count += 1&lt;BR /&gt;except (psutil.NoSuchProcess, psutil.AccessDenied):&lt;BR /&gt;fail_count += 1&lt;BR /&gt;except Exception as e:&lt;BR /&gt;print(f"Unknown error occurred while setting process {proc.info['pid']}: {e}")&lt;BR /&gt;fail_count += 1&lt;/P&gt;&lt;P&gt;return f"Successfully set {success_count} processes | Failed {fail_count} processes", True&lt;/P&gt;&lt;P&gt;def monitor_and_set_affinity(self):&lt;BR /&gt;while self.running.is_set():&lt;BR /&gt;cpu_loads = self.get_cpu_load()&lt;BR /&gt;always_on_cores = list(self.kept_cores)&lt;BR /&gt;available_indices = [i for i in range(len(cpu_loads)) if i not in self.disabled_cores]&lt;/P&gt;&lt;P&gt;sorted_cores = sorted(available_indices, key=lambda i: cpu_loads[i])&lt;BR /&gt;selected_cores = always_on_cores.copy()&lt;BR /&gt;remaining_cores = [i for i in sorted_cores if i not in always_on_cores]&lt;BR /&gt;&lt;BR /&gt;while len(selected_cores) &amp;lt; self.min_cores and remaining_cores:&lt;BR /&gt;selected_cores.append(remaining_cores.pop(0))&lt;/P&gt;&lt;P&gt;additional_cores = [i for i in remaining_cores if cpu_loads[i] &amp;lt; self.load_threshold]&lt;BR /&gt;selected_cores.extend(additional_cores)&lt;/P&gt;&lt;P&gt;if selected_cores:&lt;BR /&gt;result_msg, has_processed = self.set_cpu_affinity(selected_cores)&lt;BR /&gt;print(f"Available cores: {selected_cores}\n{result_msg}")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Unable to meet the minimum core count of {self.min_cores}")&lt;/P&gt;&lt;P&gt;self.display_cpu_load(cpu_loads)&lt;BR /&gt;if self.monitor_interval &amp;gt; 0:&lt;BR /&gt;time.sleep(self.monitor_interval)&lt;/P&gt;&lt;P&gt;def display_cpu_load(self, cpu_loads):&lt;BR /&gt;print("\nCurrent CPU core load status:")&lt;BR /&gt;for i, load in enumerate(cpu_loads):&lt;BR /&gt;status = "Disabled" if i in self.disabled_cores else "Always on" if i in self.kept_cores else "Dynamic"&lt;BR /&gt;print(f"Core {i}: {load:.1f}% ({status})")&lt;/P&gt;&lt;P&gt;def start(self):&lt;BR /&gt;if not self.running.is_set():&lt;BR /&gt;self.running.set()&lt;BR /&gt;self.thread = threading.Thread(target=self.monitor_and_set_affinity, daemon=True)&lt;BR /&gt;self.thread.start()&lt;BR /&gt;print("Monitoring started")&lt;BR /&gt;else:&lt;BR /&gt;print("Monitoring is already running")&lt;/P&gt;&lt;P&gt;def stop(self):&lt;BR /&gt;if self.running.is_set():&lt;BR /&gt;self.running.clear()&lt;BR /&gt;print("Monitoring stopped")&lt;BR /&gt;else:&lt;BR /&gt;print("Monitoring has not been started")&lt;/P&gt;&lt;P&gt;def main():&lt;BR /&gt;monitor = CPUMonitor()&lt;BR /&gt;while True:&lt;BR /&gt;print("\n=== CPU Core Management Tool ===")&lt;BR /&gt;print("1. Stop monitoring")&lt;BR /&gt;print("2. Exit")&lt;BR /&gt;&lt;BR /&gt;choice = input("Please enter an option (1-2): ")&lt;BR /&gt;&lt;BR /&gt;if choice == '1':&lt;BR /&gt;monitor.stop()&lt;BR /&gt;elif choice == '2':&lt;BR /&gt;monitor.stop()&lt;BR /&gt;print("Program exited")&lt;BR /&gt;break&lt;BR /&gt;else:&lt;BR /&gt;print("Invalid option, please try again")&lt;/P&gt;&lt;P&gt;if __name__ == "__main__":&lt;BR /&gt;main()&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 09:40:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/I-use-Python-to-enable-load-balancing-for-the-14th-generation/m-p/1669905#M2238</guid>
      <dc:creator>俊明</dc:creator>
      <dc:date>2025-02-25T09:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: I use Python to enable load balancing for the 14th generation.</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/I-use-Python-to-enable-load-balancing-for-the-14th-generation/m-p/1670941#M2239</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you for sharing your insights and your approach to optimizing CPU performance. We appreciate your interest in enhancing our product. At this time, our focus is on maintaining the current scope and features of our product. However, we will keep your feedback in mind as we continue to evaluate potential updates and improvements. Please feel free to reach out with any other ideas or questions you may have.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Stef&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2025 07:51:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/I-use-Python-to-enable-load-balancing-for-the-14th-generation/m-p/1670941#M2239</guid>
      <dc:creator>StefR_Intel</dc:creator>
      <dc:date>2025-02-28T07:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: I use Python to enable load balancing for the 14th generation.</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/I-use-Python-to-enable-load-balancing-for-the-14th-generation/m-p/1670962#M2240</link>
      <description>&lt;P&gt;This week, through multiple attempts, I discovered that the original load balancing fails due to LAG, causing it to slow down and overheat. Therefore, a faster load balancing method is needed to accomplish the task. Additionally, a large number of background processes from users also affect the operation of certain cores, leading to an unsmooth gaming experience. This is my insight from this month's adjustments for your reference.&lt;/P&gt;&lt;P&gt;Thank you for your response!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2025 08:41:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/I-use-Python-to-enable-load-balancing-for-the-14th-generation/m-p/1670962#M2240</guid>
      <dc:creator>俊明</dc:creator>
      <dc:date>2025-02-28T08:41:13Z</dc:date>
    </item>
  </channel>
</rss>

