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

Re-use memory pool between benchmark runs #1495

Merged

Conversation

benfred
Copy link
Member

@benfred benfred commented May 8, 2023

Don't recreate a new memory pool for each benchmark, and instead re-use the pool.

This significantly speeds up running the benchmarks that use a cuda memory pool. As an example running
time ./cpp/build/MATRIX_BENCH --benchmark_filter=SelectK/float/uint32_t.*/0/ which runs benchmarks for 9 different selection algorithms - the time to run the benchmarks is reduced from36.317s on branch-23.06 to 10.038s with this change.

Don't recreate a new memory pool for each benchmark, and instead
re-use the pool.

This significantly speeds up running the benchmarks that use the
cuda memory pool. As an example running
`time ./cpp/build/MATRIX_BENCH --benchmark_filter=SelectK/float/uint32_t.*/0/`
which runs benchmarks for 9 different selection algorithms -
the times are reduced from `0m36.317s` on branch-23.06 to `0m10.038s`
with this change.
@benfred benfred requested a review from a team as a code owner May 8, 2023 19:15
@benfred benfred added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels May 8, 2023
@github-actions github-actions bot added the cpp label May 8, 2023
if (use_pool_memory_resource) {
if (!memory_pool) { memory_pool.reset(new using_pool_memory_res()); }
} else if (memory_pool) {
memory_pool.reset();
Copy link
Member

Choose a reason for hiding this comment

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

I'm not following what an empty reset() is doing here. I'm reading this line as "a new memory pool is created", but your analysis shows that's not the case. Could you please explain?

Copy link
Member Author

Choose a reason for hiding this comment

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

This frees the memory being allocated by the memory pool - like in this case use_pool_memory_resource is false, and the empty reset will free up any previously allocated memory pool.

@cjnolet
Copy link
Member

cjnolet commented May 9, 2023

/merge

@rapids-bot rapids-bot bot merged commit 8816910 into rapidsai:branch-23.06 May 9, 2023
@benfred benfred deleted the cache_benchmark_memory_pool branch May 9, 2023 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants