Skip to content

Enable memory watchdog in bigmemtests on macOS and Windows #149748

@cmaloney

Description

@cmaloney

Feature or enhancement

Proposal:

Currently @bigmemtest in verbose mode (-v) reports memory usage only on Linux by reading /proc. I do a lot of work on macOS and would like to be able to quickly see the memory usage there. In this I'd also like to support Windows so all PEP 11 Tier 1 platforms are supported.

Getting the memory usage requires platform specific APIs. I'd like to add a private/itnernal C extension function in _testcapi to get process memory usage and update _MemoryWatchdog / memory_watchdog.py to use that information in its print. This keeps all platform specific pieces in C conditional compilation.

The existing code (https://github.com/python/cpython/blob/main/Lib/test/memory_watchdog.py) has comments / concerns around PID reuse. In the new code I plan to solve these by using a pipe (exists cross platform) to communicate with the watchdog. When a parent goes away, and PID becomes available for reuse, the pipe is closed. This works across the supported platforms and enables a new sub-feature: printing out the max memory when the parent closes the pipe.

cc: @vstinner

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

#75876 (comment)

Metadata

Metadata

Assignees

Labels

performancePerformance or resource usagetestsTests in the Lib/test dirtype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions