| Commit message (Collapse) | Author | Age | Files | Lines | |
|---|---|---|---|---|---|
| * | Memory leak test: take fluctuations into account (#1757) | Giampaolo Rodola | 2020-05-13 | 1 | -12/+12 |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Preamble ======= We have a [memory leak test suite](https://github.com/giampaolo/psutil/blob/e1ea2bccf8aea404dca0f79398f36f37217c45f6/psutil/tests/__init__.py#L897), which calls a function many times and fails if the process memory increased. We do this in order to detect missing `free()` or `Py_DECREF` calls in the C modules. When we do, then we have a memory leak. The problem ========== A problem we've been having for probably over 10 years, is the false positives. That's because the memory fluctuates. Sometimes it may increase (or even decrease!) due to how the OS handles memory, the Python's garbage collector, the fact that RSS is an approximation and who knows what else. So thus far we tried to compensate that by using the following logic: - warmup (call fun 10 times) - call the function many times (1000) - if memory increased before/after calling function 1000 times, then keep calling it for another 3 secs - if it still increased at all (> 0) then fail This logic didn't really solve the problem, as we still had occasional false positives, especially lately on FreeBSD. The solution ========= This PR changes the internal algorithm so that in case of failure (mem > 0 after calling fun() N times) we retry the test for up to 5 times, increasing N (repetitions) each time, so we consider it a failure only if the memory **keeps increasing** between runs. So for instance, here's a legitimate failure: ``` psutil.tests.test_memory_leaks.TestModuleFunctionsLeaks.test_disk_partitions ... Run #1: extra-mem=696.0K, per-call=3.5K, calls=200 Run #2: extra-mem=1.4M, per-call=3.5K, calls=400 Run #3: extra-mem=2.1M, per-call=3.5K, calls=600 Run #4: extra-mem=2.7M, per-call=3.5K, calls=800 Run #5: extra-mem=3.4M, per-call=3.5K, calls=1000 FAIL ``` If, on the other hand, the memory increased on one run (say 200 calls) but decreased on the next run (say 400 calls), then it clearly means it's a false positive, because memory consumption may be > 0 on second run, but if it's lower than the previous run with less repetitions, then it cannot possibly represent a leak (just a fluctuation): ``` psutil.tests.test_memory_leaks.TestModuleFunctionsLeaks.test_net_connections ... Run #1: extra-mem=568.0K, per-call=2.8K, calls=200 Run #2: extra-mem=24.0K, per-call=61.4B, calls=400 OK ``` Note about mallinfo() ================ Aka #1275. `mallinfo()` on Linux is supposed to provide memory metrics about how many bytes gets allocated on the heap by `malloc()`, so it's supposed to be way more precise than RSS and also [USS](http://grodola.blogspot.com/2016/02/psutil-4-real-process-memory-and-environ.html). In another branch were I exposed it, I verified that fluctuations still occur even when using `mallinfo()` though, despite less often. So that means even `mallinfo()` would not grant 100% stability. | ||||
| * | Process wait() improvements (#1747) | Giampaolo Rodola | 2020-05-03 | 2 | -19/+35 |
| | | | | | | | | | | | | | | | | | | | | | | | * `Process.wait()` on POSIX now returns an `enum` showing the negative which was used to terminate the process: ```python >>> import psutil >>> p = psutil.Process(9891) >>> p.terminate() >>> p.wait() <Negsignal.SIGTERM: -15> ``` * the return value is cached so that the exit code can be retrieved on then next call, mimicking `subprocess.Popen.wait()` * `Process` object provides more `status` and `exitcode` additional info on `str()` and `repr()`: ``` >>> proc psutil.Process(pid=12739, name='python3', status='terminated', exitcode=<Negsigs.SIGTERM: -15>, started='15:08:20') ``` Extra: * improved `wait()` doc * reverted #1736: `psutil.Popen` uses original `subprocess.Popen.wait` method (safer) | ||||
| * | Revert #1736: Popen inheriting from subprocess (#1744) | Giampaolo Rodola | 2020-05-01 | 1 | -34/+13 |
| | | |||||
| * | psutil.Popen: inherit from subprocess + support wait(timeout=...) parameter ↵ | Giampaolo Rodola | 2020-04-28 | 1 | -12/+15 |
| | | | | | (#1736) | ||||
| * | Parallel tests (UNIX) (#1709) | Giampaolo Rodola | 2020-04-26 | 1 | -6/+7 |
| | | |||||
| * | sensors_fans is not available on MacOS (#1710) | crusaderky | 2020-03-04 | 1 | -1/+1 |
| | | |||||
| * | Git hook for renamed/added/deleted files + flake8 print() + tidelift (#1704) | Giampaolo Rodola | 2020-02-21 | 1 | -2/+1 |
| | | |||||
| * | Add C linter script (#1698) | Giampaolo Rodola | 2020-02-18 | 2 | -1/+5 |
| | | |||||
| * | revert process_iter() exactly how it was pre #1667 | Giampaolo Rodola | 2020-02-18 | 1 | -2/+3 |
| | | |||||
| * | revert #1667 process_iter() new_only param | Giampaolo Rodola | 2020-02-18 | 1 | -12/+1 |
| | | | | | | | | | | | On a second thought I realized that process_iter() uses a global variable, so it's not thread safe. That means that if the are 2 threads using it, the first thread one calling the function (+ consume the iterator), will "steal" the processes of the second thread. psutil.cpu_percent() has the same problem. That means we have a problem can't solve with the current API and requires a lot of thinking on how to solve it as it's not obvious. | ||||
| * | refactor print colors utils | Giampaolo Rodola | 2020-02-15 | 1 | -0/+7 |
| | | |||||
| * | update doc | Giampaolo Rodola | 2020-02-15 | 1 | -0/+3 |
| | | |||||
| * | update doc | Giampaolo Rodola | 2020-02-15 | 1 | -3/+3 |
| | | |||||
| * | update doc | Giampaolo Rodola | 2020-02-15 | 1 | -10/+10 |
| | | |||||
| * | update doc | Giampaolo Rodola | 2020-02-15 | 1 | -27/+18 |
| | | |||||
| * | #1681, revert 00a3398 | Giampaolo Rodola | 2020-02-13 | 1 | -2/+0 |
| | | |||||
| * | refactor doc | Giampaolo Rodola | 2020-02-12 | 4 | -166/+47 |
| | | |||||
| * | small refact | Giampaolo Rodola | 2020-02-11 | 1 | -1/+1 |
| | | |||||
| * | fix #1681 / linux / disk_partitions: show swap | Giampaolo Rodola | 2020-02-11 | 1 | -0/+2 |
| | | |||||
| * | skip memleak tests on PyPy: they are unreliable probably because of the JIT | Giampaolo Rodola | 2020-02-10 | 1 | -2/+2 |
| | | |||||
| * | update doc | Giampaolo Rodola | 2020-02-07 | 1 | -1/+1 |
| | | |||||
| * | #1610: clarify in the doc what cpu_count means | Giampaolo Rodola | 2020-02-04 | 1 | -2/+4 |
| | | |||||
| * | [Windows] use NtQuerySystemInformation to determine process exe() (#1677) | Giampaolo Rodola | 2020-02-01 | 1 | -2/+2 |
| | | |||||
| * | Add CI testing for FreeBSD (#1671) | Giampaolo Rodola | 2020-01-24 | 1 | -0/+4 |
| | | |||||
| * | Add *new_only* parameter for process_iter() (#1667) | Giampaolo Rodola | 2020-01-18 | 1 | -20/+15 |
| | | |||||
| * | #1020: remove doc part mentionin open_files() on win is only able to list ↵ | Giampaolo Rodola | 2020-01-09 | 1 | -4/+3 |
| | | | | | files living on the C drive | ||||
| * | #1652: also drop support for Windows Server 2003 | Giampaolo Rodola | 2020-01-02 | 1 | -3/+2 |
| | | |||||
| * | Merge branch 'master' of github.com:giampaolo/psutil | Giampaolo Rodola | 2020-01-02 | 1 | -2/+2 |
| |\ | |||||
| | * | Drop windows XP support (#1652) | Giampaolo Rodola | 2020-01-01 | 1 | -2/+2 |
| | | | | | | | | | minimum supported now is Windows Vista | ||||
| * | | update/fix wait_procs() doc | Giampaolo Rodola | 2019-12-29 | 1 | -3/+3 |
| |/ | |||||
| * | Readme tidelift update (#1636) | Giampaolo Rodola | 2019-12-05 | 1 | -2/+2 |
| | | |||||
| * | total physical memory (exclusive swap). (#1634) | Thomas Güttler | 2019-12-05 | 1 | -1/+1 |
| | | | | fix #1633 | ||||
| * | update docrelease-5.6.7 | Giampaolo Rodola | 2019-11-26 | 1 | -8/+40 |
| | | |||||
| * | pre releaserelease-5.6.6 | Giampaolo Rodola | 2019-11-25 | 1 | -0/+4 |
| | | |||||
| * | #1615, 1614: remove pyproject.toml | Giampaolo Rodola | 2019-11-06 | 1 | -0/+4 |
| | | |||||
| * | pre-releaserelease-5.6.4 | Giampaolo Rodola | 2019-11-04 | 1 | -0/+4 |
| | | |||||
| * | docs: fix TypeError in example (#1580) | Jérome Perrin | 2019-11-04 | 1 | -2/+2 |
| | | | | | | | Terminate my children example had some error: log("process {} survived SIGTERM; trying SIGKILL" % p) TypeError: not all arguments converted during string formatting | ||||
| * | update doc | Giampaolo Rodola | 2019-10-17 | 1 | -7/+9 |
| | | |||||
| * | Removed a typo/copy'n'paste mistake Linux->Windows (#1588) | Bastian Ebeling | 2019-09-18 | 1 | -1/+1 |
| | | |||||
| * | Merge branch 'master' of github.com:giampaolo/psutil | Giampaolo Rodola | 2019-09-15 | 1 | -4/+4 |
| |\ | |||||
| | * | broken links fix docs/index.rst (#1555) | SteveMoto | 2019-08-27 | 1 | -3/+3 |
| | | | |||||
| | * | typo fix docs/index.rst (#1553) | SteveMoto | 2019-08-27 | 1 | -1/+1 |
| | | | |||||
| * | | update getloadavg doc | Giampaolo Rodola | 2019-09-15 | 1 | -7/+15 |
| | | | |||||
| * | | fix #1527: Linux process CPU iowait time | Giampaolo Rodola | 2019-09-07 | 1 | -6/+24 |
| |/ | |||||
| * | Connection family/type are not converted to enums (#1535) | Giampaolo Rodola | 2019-06-14 | 1 | -3/+10 |
| | | |||||
| * | update docs / HISTORY / CREDITS / @krytarowski for #1530 | Giampaolo Rodola | 2019-06-12 | 1 | -0/+2 |
| | | |||||
| * | #1515: document how to get a list of valid attrs names for as_dict() | Giampaolo Rodola | 2019-05-29 | 1 | -0/+4 |
| | | |||||
| * | Update index.rst (#1516) | Michael Yoo | 2019-05-28 | 1 | -1/+1 |
| | | |||||
| * | update CREDITS + small style fix | Giampaolo Rodola | 2019-05-08 | 1 | -0/+1 |
| | | |||||
| * | Fix Process.ionice example using wrong keyword arg (#1504) | Tongzhou Wang | 2019-05-06 | 1 | -2/+2 |
| | | |||||
