-
Notifications
You must be signed in to change notification settings - Fork 79
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
Fix the max_mem_rss measurement #192
Conversation
if resource is not None: | ||
usage = resource.getrusage(resource.RUSAGE_CHILDREN) | ||
if resource_type is None: | ||
resource_type = resource.RUSAGE_CHILDREN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not use RUSAGE_SELF on Linux, FreeBSD and other platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is called in two contexts -- one when the benchmark runs entirely in a separate subprocess, in which case we want CHILDREN
, and one when in which it runs in the same process, where we want SELF
. Saying that, it would probably clearer to not have a default value for resource_type
here.
pyperf/_process_time.py
Outdated
@@ -61,7 +61,7 @@ def bench_process(loops, args, kw, profile_filename=None): | |||
args = [args[0], "-m", "cProfile", "-o", temp_profile_filename] + args[1:] | |||
|
|||
for _ in range_it: | |||
start_rss = get_max_rss() | |||
start_rss = get_max_rss(resource.RUSAGE_CHILDREN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource.RUSAGE_CHILDREN
doesn't work on Windows: resource module is not available there.
You should add an abstraction, like having a children=True parameter for get_max_rss().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Victor Stinner <[email protected]>
In c960443, which fixed a bug in scaling the
mem_max_rss
value on Darwin, I inadvertently changed the measurement from usingRUSAGE_SELF
toRUSAGE_CHILDREN
. This has resulted in the measurements being much coarser and incorrect on Darwin. This reverts to the old correct behavior.