<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/python-packages/psutil.git/scripts/internal/winmake.py, branch github-actions</title>
<subtitle>github.com: giampaolo/psutil.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/'/>
<entry>
<title>Remove Travis and Cirrus, use GH also for FreeBSD (#1880)</title>
<updated>2020-11-15T20:54:42+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-11-15T20:54:42+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=e58b0fdaeaedd73a0ca19ad23a63874708d86b91'/>
<id>e58b0fdaeaedd73a0ca19ad23a63874708d86b91</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix py 3.9 [WinError 998] Invalid access to memory location (#1866)</title>
<updated>2020-10-31T14:37:31+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-10-31T14:37:31+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=9aba2efe6cee0a343002d0453674aca68a7b7aec'/>
<id>9aba2efe6cee0a343002d0453674aca68a7b7aec</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Wheels 3 (#1764)</title>
<updated>2020-05-23T15:34:17+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-05-23T15:34:17+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=bb2c6cfb6aa83a8557051f3fd1d451bd419dfc04'/>
<id>bb2c6cfb6aa83a8557051f3fd1d451bd419dfc04</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>rename memleaks script</title>
<updated>2020-05-13T14:45:11+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-05-13T14:45:11+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=18e88998a5f25ab9335afbaacfa3db46287bfa1f'/>
<id>18e88998a5f25ab9335afbaacfa3db46287bfa1f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Memory leak test: take fluctuations into account (#1757)</title>
<updated>2020-05-12T22:40:04+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-05-12T22:40:04+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=6adcca6c9fda5a36e923bfca3591b972e98a0ce5'/>
<id>6adcca6c9fda5a36e923bfca3591b972e98a0ce5</id>
<content type='text'>
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 (&gt; 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 &gt; 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 &gt; 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.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 (&gt; 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 &gt; 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 &gt; 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.</pre>
</div>
</content>
</entry>
<entry>
<title>Add new TestFdsLeak test class (#1752)</title>
<updated>2020-05-06T19:58:49+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-05-06T19:58:49+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=e1ea2bccf8aea404dca0f79398f36f37217c45f6'/>
<id>e1ea2bccf8aea404dca0f79398f36f37217c45f6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>fix some memleak tests on win</title>
<updated>2020-05-05T18:16:25+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-05-05T18:16:25+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=8ad353bc515d7765e7dc3dfaaa8f9f6db4f85aba'/>
<id>8ad353bc515d7765e7dc3dfaaa8f9f6db4f85aba</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Drastically improve "make test/build" speed.</title>
<updated>2020-05-01T11:37:37+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-05-01T11:37:37+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=6f4e38220d9da33931ff9a307d20025a6916c258'/>
<id>6f4e38220d9da33931ff9a307d20025a6916c258</id>
<content type='text'>
Doing "make install" before any test is slow and not really necessary.
Instead do "make build", and remove the part import setuptools and test
psutil can be imported (do that in make install instead).
This way I went down from 0.8 secs (install phase before starting the test) to 0.3 secs!
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Doing "make install" before any test is slow and not really necessary.
Instead do "make build", and remove the part import setuptools and test
psutil can be imported (do that in make install instead).
This way I went down from 0.8 secs (install phase before starting the test) to 0.3 secs!
</pre>
</div>
</content>
</entry>
<entry>
<title>Per-test file cleanup and new PsutilTestCase (#1743)</title>
<updated>2020-04-30T21:45:08+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-04-30T21:45:08+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=3480e1b05f3e98744a1b6aa6fe286caac86e6bbd'/>
<id>3480e1b05f3e98744a1b6aa6fe286caac86e6bbd</id>
<content type='text'>
Test files/dirs are now removed after each test. when invoked via self.get_testfn().
Until now test files were stored in a global variable and were removed at process exit, via atexit.register(), but this didn't work with parallel tests because the fork()ed workers use os._exit(0), preventing cleanup functions to run.
All test classes now inherit from PsutilTestCase class, which provides the most important methods requiring an automatic cleanup (get_test_subprocess() and others).</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Test files/dirs are now removed after each test. when invoked via self.get_testfn().
Until now test files were stored in a global variable and were removed at process exit, via atexit.register(), but this didn't work with parallel tests because the fork()ed workers use os._exit(0), preventing cleanup functions to run.
All test classes now inherit from PsutilTestCase class, which provides the most important methods requiring an automatic cleanup (get_test_subprocess() and others).</pre>
</div>
</content>
</entry>
<entry>
<title>Parallel build (#1741)</title>
<updated>2020-04-30T02:23:08+00:00</updated>
<author>
<name>Giampaolo Rodola</name>
<email>g.rodola@gmail.com</email>
</author>
<published>2020-04-30T02:23:08+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/python-packages/psutil.git/commit/?id=997bc0d92935b8033e28b79d8dd0595ba4462960'/>
<id>997bc0d92935b8033e28b79d8dd0595ba4462960</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
