Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

: Optimization Request: Reducing the Number of windows.OpenProcess Calls When Gathering Name, CreateTime, and PPID #1608

Open
vela-security opened this issue Mar 6, 2024 · 1 comment

Comments

@vela-security
Copy link

Hello,

I'm currently facing a performance bottleneck in my application due to the need to repeatedly call windows.OpenProcess to obtain information such as the process name, creation time, and parent process ID (PPID) for the same process. This repeated operation significantly impacts the overall performance and efficiency of the process information gathering routine in my application.

I'm looking for a way to optimize this aspect, specifically by minimizing the number of times windows.OpenProcess needs to be invoked for the same process. The goal is to improve the performance of my application by reducing the overhead associated with these repetitive system calls.

Is there a recommended approach or best practice for consolidating these operations or somehow reusing the handle obtained from windows.OpenProcess to get all the required information (name, creation time, PPID) in a more efficient manner? Any suggestions or guidance on how to achieve this optimization would be greatly appreciated.

Thank you for your attention to this issue.

@shirou
Copy link
Owner

shirou commented Mar 10, 2024

One idea is to do cache. gopsutil has a function called EnableBoottimeCache that allows the startup time to be cached. This is mainly for Linux.

Also, psutil can use cache. I believe the number of calls can be reduced by introducing this feature. But no plans at the moment, PR is always welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants