gh-150114: Log the memory usage in regrtest#150255
Conversation
On Linux, log the total memory usage of all Python processes. Read the private memory in /proc/pid/smaps.
|
I looked manually at logs to get minimum and maximum memory usage:
"Ubuntu (free-threading) / build and test (ubuntu-24.04)" uses 1.5x more memory (1.1 GiB) than |
|
Oh, "Tests / Ubuntu (free-threading) / build and test (ubuntu-24.04) (pull_request)" failed with issue gh-150114: I restarted the job. |
|
Let's see how this code goes on the CI / buildbots before considering to backport this new regrtest feature to stable branches (3.13, 3.14, 3.15). |
| @@ -0,0 +1,2 @@ | |||
| On Linux, regrtest now logs the total memory usage of all Python processes. | |||
There was a problem hiding this comment.
It doesn’t the process’s children I think, is it possible to include them?
Also, why was the sequential runner omitted?
Getting an accurate value of the memory usage on Linux is complicated. The RSS memory for example is higher than "expected": $ ./python
>>> import test.libregrtest.utils, os
>>> test.libregrtest.utils.get_process_memory_usage(os.getpid()) / 1024**2
26.28125
>>> rc=os.system(f"grep ^VmRSS /proc/{os.getpid()}/status")
VmRSS: 36204 kBI reused the private memory from About child processes, you're correct that they are not included, only worker test processes and the main test process. I chose to start simple to debug the issue gh-150114. Maybe it would make sense to include them, I'm not sure. Well, it was also simpler to only read the usage of worker processes, since we can easily get their pid.
Oh, it's just that I wanted to merge a quick change to debug the issue. I wrote gh-150264 follow-up issue to also log the memory usage when tests are run sequentially. |
|
By the way, here is a "screenshot" of the new feature: it adds "mem: xxx MiB" to the output. |
On Linux, log the total memory usage of all Python processes. Read the private memory in /proc/pid/smaps.