Skip to content

gh-75876: Correct the memory use declared by some bigmem tests - #155307

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:bigmemtest-memuse
Aug 7, 2026
Merged

gh-75876: Correct the memory use declared by some bigmem tests#155307
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:bigmemtest-memuse

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Some bigmem tests declare less memory than they use. Measured as the peak RSS of a process running a single test with -M:

test declared measured
TupleTest.test_repeat_large_2 12.0 GiB 24.2 GiB 2.02x
HashLibTestCase.test_case_md5_huge 4.0 GiB 8.3 GiB 2.06x
HashLibTestCase.test_case_md5_uintmax 4.0 GiB 8.3 GiB 2.06x
ZlibDecompressorTest.testDecompress4G 13.2 GiB 16.3 GiB 1.23x
BigmemTclTest.test_huge_string_builtins 4.0 GiB 6.0 GiB 1.51x
ReTests.test_large_subn 36.0 GiB 37.7 GiB 1.05x

test_repeat_large_2 keeps 3 tuples of pointers alive, as test_repeat_small and test_repeat_large do, but declared 12 instead of pointer_size * 3, which is the count for a 32-bit build.

The md5 tests pass the data to check_file_digest(), which copies all of it into an io.BytesIO().

testDecompress4G keeps the data, the compressed and the decompressed bytes alive at the same time, and the decompressor grows its output buffer.

These are the only tests which use more memory than they declare. The other 227 bigmem tests were measured too: the largest excess is 1.03x, and it is 20 MiB in the median.

Measured with a limited address space and the peak RSS of the process:

* TupleTest.test_repeat_large_2 keeps 3 tuples of pointers alive, as its
  siblings do, but declared the count for a 32-bit build.
* The md5 tests hash the data and a io.BytesIO() copy of it.
* testDecompress4G keeps the data, the compressed and the decompressed
  bytes alive, and the decompressor grows its output buffer.
* test_huge_string_builtins uses 3 times the string size, not 2.
* test_large_subn uses a bit more than the 18 times it declared.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Aug 7, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Aug 7, 2026
@serhiy-storchaka serhiy-storchaka added skip news needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 7, 2026
@serhiy-storchaka
serhiy-storchaka merged commit e469fa9 into python:main Aug 7, 2026
59 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@serhiy-storchaka
serhiy-storchaka deleted the bigmemtest-memuse branch August 7, 2026 06:32
@bedevere-app

bedevere-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

GH-155312 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 7, 2026
@bedevere-app

bedevere-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

GH-155313 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 7, 2026
@bedevere-app

bedevere-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

GH-155314 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 7, 2026
serhiy-storchaka added a commit that referenced this pull request Aug 7, 2026
…GH-155307) (GH-155314)

Measured with a limited address space and the peak RSS of the process:

* TupleTest.test_repeat_large_2 keeps 3 tuples of pointers alive, as its
  siblings do, but declared the count for a 32-bit build.
* The md5 tests hash the data and a io.BytesIO() copy of it.
* testDecompress4G keeps the data, the compressed and the decompressed
  bytes alive, and the decompressor grows its output buffer.
* test_huge_string_builtins uses 3 times the string size, not 2.
* test_large_subn uses a bit more than the 18 times it declared.
(cherry picked from commit e469fa9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Aug 7, 2026
…GH-155307) (GH-155313)

Measured with a limited address space and the peak RSS of the process:

* TupleTest.test_repeat_large_2 keeps 3 tuples of pointers alive, as its
  siblings do, but declared the count for a 32-bit build.
* The md5 tests hash the data and a io.BytesIO() copy of it.
* testDecompress4G keeps the data, the compressed and the decompressed
  bytes alive, and the decompressor grows its output buffer.
* test_huge_string_builtins uses 3 times the string size, not 2.
* test_large_subn uses a bit more than the 18 times it declared.
(cherry picked from commit e469fa9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant