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

bpo-40630: add tracemalloc.reset_peak #20102

Merged
merged 10 commits into from
May 22, 2020

Conversation

huonw
Copy link
Contributor

@huonw huonw commented May 15, 2020

The reset_peak function sets the peak memory size to the current size,
representing a resetting of that metric. This allows for recording the
peak of specific sections of code, ignoring other code that may have
had a higher peak (since the most recent tracemalloc.start() or
tracemalloc.clear_traces()` call).

https://bugs.python.org/issue40630

The reset_peak function sets the peak memory size to the current size,
representing a resetting of that metric. This allows for recording the
peak of specific sections of code, ignoring other code that may have
had a higher peak (since the most recent `tracemalloc.start()` or
tracemalloc.clear_traces()` call).
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@huonw

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@huonw
Copy link
Contributor Author

huonw commented May 15, 2020

Thanks for the speedy review @vstinner 😄

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.

Can you please add a new "tracemalloc" sub-section in Doc/whatsnew/3.10.rst, in the "Improved Modules" section, and describe your change? You can copy/paste the NEWS entry and add (Contributed by ...): see Doc/whatsnew/3.9.rst for examples.

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 but I would prefer to update directly What's New in Python 3.10.

@huonw
Copy link
Contributor Author

huonw commented May 20, 2020

I've added it. It looks like this just missed 3.9 beta cut off? Does that mean it likely has to wait a year or more to be released?

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, apart the missing "versionadded" markup.

@ambv: @huonw would like to get it in Python 3.9, but we missed the feature freeze by 2 days. IMO such feature can wait for Python 3.10. On the other side, there is (very) low risk of regression. It's up to you, Łukasz. I'm waiting for @ambv feedback before merging, since currently it's documented at new feature in Python 3.10.

meaningfully compared to snapshots taken after the call.

See also :func:`get_traced_memory`.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, you need to add ".. versionadded:: 3.10".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@huonw
Copy link
Contributor Author

huonw commented May 22, 2020

It's fine to land for 3.10; I was just a little disconcerted and unhappy that we missed the feature cut-off by days, and so will probably have to wait for an extra year for this to be released.

@vstinner vstinner merged commit 8b62644 into python:master May 22, 2020
@vstinner
Copy link
Member

Thanks, I merged your PR into master.

The good news if that Python 3.10 will be the first release with a short dev cycle of only 1 year except of 18 months.

@ambv
Copy link
Contributor

ambv commented May 22, 2020 via email

arturoescaip pushed a commit to arturoescaip/cpython that referenced this pull request May 24, 2020
The reset_peak function sets the peak memory size to the current size,
representing a resetting of that metric. This allows for recording the
peak of specific sections of code, ignoring other code that may have
had a higher peak (since the most recent `tracemalloc.start()` or
tracemalloc.clear_traces()` call).
@vstinner
Copy link
Member

@ambv: "I would be fine for this to land in 3.9b2."

Oh ok. @huonw: Do you want to backport this change to 3.9? Copy/paste-like but replaced 3.10 with 3.9. And then we can cleanup the master branch to replace 3.10 with 3.9 as well.

huonw added a commit to huonw/cpython that referenced this pull request May 30, 2020
…2644)

The reset_peak function sets the peak memory size to the current size,
representing a resetting of that metric. This allows for recording the
peak of specific sections of code, ignoring other code that may have
had a higher peak (since the most recent `tracemalloc.start()` or
tracemalloc.clear_traces()` call).
@huonw
Copy link
Contributor Author

huonw commented May 31, 2020

Thanks @ambv and @vstinner, I've opened #20545 and #20546 with updates for 3.9.

@huonw huonw deleted the issue40630-tracemalloc-reset-peak branch May 31, 2020 11:06
vstinner pushed a commit that referenced this pull request Jun 1, 2020
* bpo-40630: Add tracemalloc.reset_peak (GH-20102, cherrypick 8b62644)

The reset_peak function sets the peak memory size to the current size,
representing a resetting of that metric. This allows for recording the
peak of specific sections of code, ignoring other code that may have
had a higher peak (since the most recent `tracemalloc.start()` or
tracemalloc.clear_traces()` call).

* Adjust docs to point to 3.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants