Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-120754: Update estimated_size in C truncate #121357

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

cmaloney
Copy link
Contributor

@cmaloney cmaloney commented Jul 4, 2024

goal: Fix buildbot failure https://github.com/python/cpython/pull/120755

Sometimes a large file is truncated (test_largefile). While estimated_size is used as a estimate (the read will get all the bytes in the file when it is wrong), that it is much larger than the actual size of data can result in a significant over allocation and sometimes lead to a MemoryError / running out of memory.

This brings the C implementation to match the Python _pyio implementation.

cc: @vstinner

I've been unable to reproduce the failure locally so far by running ./build/python -bb -E -Wd -m test -r -w -uall test_largefile. My suspicion is that the AMD64 box has limited memory. Working to try and test peak memory usage in the test / if that went down

Sometimes a large file is truncated (test_largefile). While
estimated_size is used as a estimate (the read will stil get the number
of bytes in the file), that it is much larger than the actual size of
data can result in a significant over allocation and sometimes lead to
a MemoryError / running out of memory.

This brings the C implementation to match the Python _pyio
implementation.
@cmaloney cmaloney changed the title gh-120754: Update size_estimated in C truncate gh-120754: Update estimated_size in C truncate Jul 4, 2024
@cmaloney
Copy link
Contributor Author

cmaloney commented Jul 4, 2024

Validated memory usage decrease by running under https://www.gnu.org/software/time/

/usr/bin/time -v ./python -bb -E -Wd -m test -r -w -uall test_largefile -vvv

Maximum resident set size (kbytes): 2464692 (main) -> 24532 (this pr)

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@vstinner vstinner enabled auto-merge (squash) July 4, 2024 09:32
@vstinner vstinner merged commit 06a1c3f into python:main Jul 4, 2024
38 checks passed
@cmaloney cmaloney deleted the cmaloney/fix_largefile_amd64 branch July 4, 2024 17:07
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
Sometimes a large file is truncated (test_largefile). While
estimated_size is used as a estimate (the read will stil get the number
of bytes in the file), that it is much larger than the actual size of
data can result in a significant over allocation and sometimes lead to
a MemoryError / running out of memory.

This brings the C implementation to match the Python _pyio
implementation.
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
Sometimes a large file is truncated (test_largefile). While
estimated_size is used as a estimate (the read will stil get the number
of bytes in the file), that it is much larger than the actual size of
data can result in a significant over allocation and sometimes lead to
a MemoryError / running out of memory.

This brings the C implementation to match the Python _pyio
implementation.
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.

2 participants