Skip to content

TST: fix flaky memory growth tests - #33417

Merged
ngoldbaum merged 4 commits into
numpy:mainfrom
ngoldbaum:memory-test-isolation
Nov 23, 2026
Merged

ngoldbaum merged 4 commits into
numpy:mainfrom
ngoldbaum:memory-test-isolation

Conversation

@ngoldbaum

Copy link
Copy Markdown
Member

PR summary

Fixes #33409. Also see #33374, this revises what we ended up with there.

Move all tests that rely on tracemalloc to run in a subprocess, including the new memory growth assert helper added in #33241. Tracemalloc is process-wide, so pytest-xdist workers can interfere with the measurement this test does. I think that's what happened here: https://github.com/numpy/numpy-release/actions/runs/44977466535/job/137070536035

I also revised what we came up with in #33374 because of the failure seen here: https://github.com/numpy/numpy/actions/runs/45045409029/job/137278823294?pr=33412

The Darwin legacy malloc might be used if the SDK used to build Python is sufficiently old, as in the conda-forge test run above. There isn't a public API to determine which malloc implementation is used, so the only way to avoid flaky tests is to not run the RLIMIT_AS address space memory growth tests on MacOS.

AI Disclosure

I worked on this with an AI model.

@jorenham jorenham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some superficial opinionated suggestions; hope you don't mind

Comment thread numpy/_core/tests/test_multiarray.py Resolved
Comment thread numpy/testing/_private/utils.py Resolved
Comment thread numpy/testing/_private/utils.py Resolved

@ikrommyd ikrommyd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good. I'd honestly be fine with not having memory growth tests at all as well cause they are difficult to do in CI anyways but this is fine. Doing it on linux only like you do in the PR is enough, we only need one system to measure these things.

@ngoldbaum

Copy link
Copy Markdown
Member Author

I think they're worth having. If they continue to cause issues I'll get rid of them though.

@ngoldbaum
ngoldbaum merged commit 56d8b17 into numpy:main Nov 23, 2026
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failure in CI: test_ufunc_fixed_width_out_releases_buffer

3 participants