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

Measure USS on Windows #746

Merged
merged 5 commits into from
Feb 4, 2016
Merged

Measure USS on Windows #746

merged 5 commits into from
Feb 4, 2016

Conversation

EricRahm
Copy link
Contributor

This adds a USS (unique set size, aka private working set) measurement to memory_info_ex on Windows.

Performance before patch:

$ python -m timeit -s "import psutil; p = psutil.Process()" "p.memory_info_ex()"
100000 loops, best of 3: 3.44 usec per loop

Performance after patch:

$ python -m timeit -s "import psutil; p = psutil.Process()" "p.memory_info_ex()"
10000 loops, best of 3: 44 usec per loop

So slower, but not as bad as Linux and OSX.

@EricRahm
Copy link
Contributor Author

This is based off the memory reporting implementation in Firefox.

@EricRahm
Copy link
Contributor Author

It would appear AppVeyor is unhappy about the usage of stdint.h on Windows, I'm guessing Visual C++ for Python 9 does not include it, but it was in my path due to having a full-fledged modern msvc install.

@fbenkstein
Copy link
Collaborator

Python 2.7 still has to be compiled with Visual Studio 2008 which does not support stdint.h.

@giampaolo
Copy link
Owner

Related: #752

}

return result;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation should be 4 spaces. Also, there's no need to put this in a separate file. You can use psutil/arch/windows/process_info.c instead.

#include <psapi.h>

BOOL
calc_uss(DWORD target, unsigned long long* aN)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second thought I would prefer you define this in psutil/_psutil_windows.c as proc_memory_uss.
From the python file (psutil/_pswindows.py) after you call cext.psutil_proc_memory_info (or cext.psutil_proc_memory_info_2 you will call cext.proc_memory_uss to get USS stats separately.

@EricRahm
Copy link
Contributor Author

EricRahm commented Feb 3, 2016

@giampaolo The latest pushes should cover your code review comments.

DWORD info_array_size;
PSAPI_WORKING_SET_INFORMATION* info_array;
SYSTEM_INFO system_info;
PyObject* result = NULL;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename this to py_result

@EricRahm
Copy link
Contributor Author

EricRahm commented Feb 3, 2016

@giampaolo ee6024f should address the final comments.

giampaolo added a commit that referenced this pull request Feb 4, 2016
@giampaolo giampaolo merged commit 75859a2 into giampaolo:master Feb 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants