diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2022-05-18 21:20:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-18 21:20:37 +0200 |
commit | f1f299527634a425cb34b621d6201fa9172d3529 (patch) | |
tree | 7cb80b97b27aa56c830986c533b9f5bb255264b3 /HISTORY.rst | |
parent | 33981759a67601b91d925a14403077e8d218c015 (diff) | |
download | psutil-f1f299527634a425cb34b621d6201fa9172d3529.tar.gz |
[Linux] Speedup `Process.full_memory_info()` (#2108)
`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
```
Diffstat (limited to 'HISTORY.rst')
-rw-r--r-- | HISTORY.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/HISTORY.rst b/HISTORY.rst index 8f2aaa32..49242a6e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,9 @@ XXXX-XX-XX ``/proc`` pseudo files line by line. This should help having more consistent results. - 2057_, [OpenBSD]: add support for `cpu_freq()`_. +- 2107_ [Linux]: `Process.memory_full_info()`_ (reporting process USS/PSS/Swap + memory) now reads ``/proc/pid/smaps_rollup`` instead of ``/proc/pids/smaps``, + which makes it 5 times faster. **Bug fixes** |