-
Notifications
You must be signed in to change notification settings - Fork 916
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
Add peak memory usage tracking to cuIO benchmarks #7770
Add peak memory usage tracking to cuIO benchmarks #7770
Conversation
And sample use in parquet writer bench
Separate out memory_tracking_resource into its own header and remove association with benchmark fixture
Co-authored-by: David <[email protected]>
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 is way cool.
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.
Great work. Mostly got questions :)
(requesting changes just for the copyright years)
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource(); | ||
cudf::memory_tracking_resource<rmm::mr::device_memory_resource> tracking_mr(mr); |
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 need to make changes to all benchmarks. Do you want to add this in a separate PR?
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.
No I just wanted to get reviews on the method first, before going ahead and changing all the benchmarks. In the first commit, I made the tracking resource part of the base fixture and that automatically enabled it for every benchmark. But a problem with that was that it tracked memory usage for the setup as well.
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.
Added in 4664f9a
|
||
state.SetBytesProcessed(data_size * state.iterations()); | ||
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size(); |
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.
Could we use this to catch memory leaks in tests (just query current instead of max on exit)?
Edit: leaks are pretty unlikely given libcudf's coding style, we probably don't need to invest time into this check.
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.
It would be pretty easy. But since this is more of a test (curr value should always be 0 at the end) rather than a benchmark, should we make this opt-in? If anyone suspects a leak, they can add a check.
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.
I was thinking of adding this check to the unit tests, rather than benchmarks.
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.
Well sure. I can do that in a subsequent PR.
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.
I just realized that any leak we have would probably be due to memory allocated without the rmm resource. Anything with rmm is likely using some RAII object to hold the memory. And this doesn't track non-rmm allocated memory.
|
||
state.SetBytesProcessed(data_size * state.iterations()); | ||
state.counters["peak_memory_usage"] = tracking_mr.max_allocated_size(); |
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.
Are you getting consistent numbers between runs? @kaatish mentioned that the peak usage varies when running the ORC writer benchmark.
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.
I just tested, it reports the same number for corresponding benchmarks across runs for ORC. @kaatish, what method did you use to test peak memory usage? If you're using nsys, you need to turn off the pool allocator.
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.
I used the script referenced in issue #7661 which calls pynvml methods.
Codecov Report
@@ Coverage Diff @@
## branch-21.08 #7770 +/- ##
===============================================
Coverage ? 10.53%
===============================================
Files ? 116
Lines ? 18916
Branches ? 0
===============================================
Hits ? 1993
Misses ? 16923
Partials ? 0 Continue to review full report at Codecov.
|
Should this be going into 0.19. I thought we were in burndown. |
Why not make this apply to all benchmarks by putting it in the base fixture? |
I did that previously in this PR c34b32b but changed it to per benchmark in b9147f4 because adding it to base fixture would cause allocations during the setup stage to also be included. We only care about the allocations happening in the API being benchmarked. |
What allocations are there in the setup stage? Can't those be moved before where you create the statistics tracking resource and set it as the default? |
Setup happens in most benchmarks' primary function. e.g. |
I see. Perhaps we can provide another function in the fixture that all benchmarks can use to initiate statistics logging... |
How about an RAII object that does this 8d85fa9. |
I like it. Easy to add to other benchmarks. |
rerun tests |
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.
Looks good, just got an optional nitpick.
Co-authored-by: Vukasin Milovanovic <[email protected]>
@gpucibot merge |
Uses
rmm::mr::statistics_resource_adapter
to track peak memory usage in cuIO benchmarks.