| Commit message (Collapse) | Author | Age | Files | Lines |
| | |
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| | |
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |\ |
|
| | |
| |
| | |
Signed-off-by: asztalosdani <asztalosdani@gmail.com>
|
| |/
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |\ |
|
| | | |
|
| |/
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
|
|
| |
go backwards
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |\ |
|
| | | |
|
| |/
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
|
|
|
|
|
|
| |
This has always been cause of confusion, e.g. see:
https://github.com/giampaolo/psutil/pull/1727#issuecomment-698934643
Removed the reference to "physical" from dostrings, functions and test.
I still left it in the doc though, as it's more explanatory.
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| |
|
|
| |
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
"seconds since the epoch" (value returned by `time.time()`) doesn't
depend on the local time zone. It is the same time instance around the
world. It is not in any particular time zone:
```python
import datetime as DT
import zoneinfo
local_time = DT.datetime.fromtimestamp(seconds_since_epoch) # naive datetime object representing local time
utc_time = DT.datetime.utcfromtimestamp(seconds_since_epoch) # naive datetime object representing utc time
la_time = DT.datetime.fromtimestamp(seconds_since_epoch, zoneinfo.ZoneInfo("America/Los_Angeles")) # timezone aware dt
```
Here `local_time`, `utc_time`, `la_time` may correspond to different
clock times but it is exactly the same time instance.
|
| | |
|
| |
|
| |
RPM is actually revolutions per minute, current docs say its rounds per minute
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
| |
Changed system_user to children_system to match the named tupple and expected behaviour. Change description to match.
|
| |
|
| |
Fixed typo in documentation of user.name attribute.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|