Jayashree-ux / process_monitor

Real-Time Process Monitoring: Displays current processes with their CPU and memory usage using the psutil library. Export to CSV/JSON: Can export process data to either a CSV or JSON file, based on user input. Command Line Interface: Supports CLI arguments for setting intervals between updates and exporting process data.
0 stars 1 forks source link

Inefficient Polling mechanisms causing the system overuse #2

Open Jayashree-ux opened 1 month ago

Jayashree-ux commented 1 month ago

Inefficient Polling: The current version continuously queries system data without any delays, causing the CPU to remain busy even when no new information needs to be updated.

Lack of Sleep Interval: There is no delay or "sleep" mechanism between polling cycles, making the program unnecessarily consume CPU resources even during idle periods.

Unoptimized System Calls: System calls for process details are repeated in rapid succession, leading to bottlenecks and higher system load, especially when the user is tracking numerous processes.

Jayashree-ux commented 1 month ago

The issue here is that the utility runs without any delay, causing high CPU usage. We'll fix this by implementing a more efficient polling system with a sleep interval. Added Sleep Interval: In the run method, we introduced a time.sleep(interval) to reduce CPU load by avoiding constant polling. Interval Option: The user can specify the time interval (in seconds) between each monitoring cycle via the command line, reducing the load on the CPU.