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

Linux smaps rollup #2108

Merged
merged 9 commits into from May 18, 2022
Merged

Linux smaps rollup #2108

merged 9 commits into from May 18, 2022

Conversation

giampaolo
Copy link
Owner

@giampaolo giampaolo commented May 18, 2022

Summary

Description

Process.memory_full_info() (reporting proecss USS/PSS/Swap memory) now reads /proc/pid/smaps_rollup instead of /proc/pids/smaps which makes it 5 times faster.

Without patch:

~/svn/psutil {linux-smaps-rollup}$ python3 -m timeit -s "import psutil; p = psutil.Process()" "p.memory_full_info()"
500 loops, best of 5: 518 usec per loop

With patch (5 times faster):

~/svn/psutil {linux-smaps-rollup}$ python3 -m timeit -s "import psutil; p = psutil.Process()" "p.memory_full_info()"
2000 loops, best of 5: 111 usec per loop

make test-memleaks suite, who heavily rely on Process.memory_full_info(), also received a nice speedup:

Before patch:

$ make test-memleaks
----------------------------------------------------------------------
Ran 99 tests in 1.646s

OK (skipped=9)
SUCCESS

After patch:

$ make test-memleaks
----------------------------------------------------------------------
Ran 99 tests in 1.195s

OK (skipped=9)
SUCCESS

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

Successfully merging this pull request may close these issues.

[Linux] Performance optimization for Process.memory_full_info()
1 participant