giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.31k stars 1.39k forks source link

[Windows] batch multiple process info in one shot #2463

Open giampaolo opened 1 month ago

giampaolo commented 1 month ago

This is a reminder ticket to continue the discussion started in https://github.com/giampaolo/psutil/issues/2366. Recap: on Windows we use NtQuerySystemInformation(SystemProcessInformation) to collect multiple process info about all PIDs (Windows is the only platform which allows this). This data structure is used on a per-process basis, meaning it's discarded (or to put it another way, it's unnecessarily fetched for every Process instance).

psutil.process_iter() could be tweaked in a way that it passes the entire structure to the Process instances, and this way we would have a performance boost. In detail, read the considerations written in https://github.com/giampaolo/psutil/issues/2366#issuecomment-2393071740.