[go: up one dir, main page]

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

- Adding patch from issue #1989 to correct cpu_percent on thread ID #2061

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RobinC-18
Copy link

Summary

  • OS: Linux
  • Bug fix: yes
  • Type: core
  • Fixes: 1989

Description

Applying the patch described in issue #1989, to enable a user to query the cpu_percent of a TID and it to return the correct values for that specific thread, rather than of the master_pid.

…read ID

Signed-off-by: Robin Cowley <robincowley18@gmail.com>
@foamdino
Copy link
foamdino commented Jul 7, 2022

This patch is something we're using in production in a local fork at the moment. Would it be possible to get this merged into mainline so we can retire our local fork?

@ajmmm
Copy link
ajmmm commented May 24, 2023

Would be great if this PR was accepted - also having to maintain my own fork right now. :(

@ajmmm
Copy link
ajmmm commented Jun 14, 2024

@giampaolo is there any chance of getting this PR reviewed and merged please?
Thanks!

@giampaolo
Copy link
Owner
giampaolo commented Jun 14, 2024

The reason why I didn't merge this yet was because reading /proc/PID/status on __init__ has a performance penalty.

Before patch:

~/svn/psutil {master}$ python3 -m timeit -s "import psutil" "psutil.Process()"
50000 loops, best of 5: 9.33 usec per loop

After patch:

~/svn/psutil {master}$ python3 -m timeit -s "import psutil" "psutil.Process()"
20000 loops, best of 5: 17.7 usec per loop

It's not big but still...
I wanted to check if there is some other way to identify whether PID is a TID, but I am afraid there isn't. :(

@RobinC-18
Copy link
Author

Hi @giampaolo, thanks for the reply.

We could look at a refactor that removes the check for the PID identity and whether it is a TID into an API that is only run when the caller explicitly asks for it to be checked? That means the __init__ performance would stay the same, however the option would be there is a caller wanted to know whether a PID was a TID or not?

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

Successfully merging this pull request may close these issues.

4 participants