Skip to content

Skip zero-byte binning deallocations#2403

Draft
bdice wants to merge 1 commit into
rapidsai:mainfrom
bdice:pr-skip-zero-byte-binning-deallocations
Draft

Skip zero-byte binning deallocations#2403
bdice wants to merge 1 commit into
rapidsai:mainfrom
bdice:pr-skip-zero-byte-binning-deallocations

Conversation

@bdice
Copy link
Copy Markdown
Collaborator

@bdice bdice commented May 17, 2026

Description

Makes zero-byte binning_memory_resource deallocations no-ops. This avoids routing zero-byte frees through bin selection, which could otherwise dispatch to an unrelated bin resource.

Validation

  • BINNING_MR_TEST
  • BINNING_MR_PTDS_TEST
  • BINNING_MR_REF_TEST
  • BINNING_MR_REF_PTDS_TEST
  • Pre-commit on touched files

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@bdice bdice added bug Something isn't working non-breaking Non-breaking change labels May 17, 2026
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 17, 2026

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Optimized memory deallocation operations by implementing efficient handling of zero-byte requests, reducing unnecessary resource processing and improving overall system efficiency.
  • Tests

    • Added comprehensive test coverage to ensure zero-byte deallocation requests properly skip memory resource operations across both synchronous and asynchronous execution paths.

Walkthrough

This PR optimizes zero-byte deallocation in the binning memory resource by adding early-return checks to both deallocate and deallocate_sync methods. When deallocating zero bytes, the calls now return immediately without invoking downstream memory resource operations. A new test validates that both deallocation paths correctly skip the downstream calls for zero-byte requests.

Changes

Zero-byte deallocation optimization

Layer / File(s) Summary
Zero-byte deallocation fast-path
cpp/src/mr/detail/binning_memory_resource_impl.cpp
deallocate and deallocate_sync methods return immediately when bytes == 0, preventing downstream memory resource calls for zero-size deallocations.
Zero-byte deallocation test
cpp/tests/mr/binning_mr_tests.cpp
Test file imports mock resource header and creates test namespace; new ZeroByteDeallocateIsNoOp test verifies both deallocate and deallocate_sync skip downstream calls for zero-byte requests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • harrism
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Skip zero-byte binning deallocations' directly and specifically summarizes the main change: adding early-return checks to prevent zero-byte deallocations from being processed.
Description check ✅ Passed The description clearly explains the purpose of the changes (avoiding routing zero-byte frees through bin selection) and documents validation steps and checklist completion.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cpp/tests/mr/binning_mr_tests.cpp (1)

31-43: ⚡ Quick win

Add alignment parameter for consistency.

Line 42 calls deallocate_sync with only 2 arguments (ptr and bytes), while line 41 explicitly passes the alignment parameter to deallocate. Based on the implementation signature at lines 87-89 of the implementation file, deallocate_sync requires 3 parameters: ptr, bytes, and alignment.

For consistency and clarity, consider adding the alignment parameter:

📝 Suggested change for consistency
   mr.deallocate(cuda_stream_view{}, nullptr, 0, rmm::CUDA_ALLOCATION_ALIGNMENT);
-  mr.deallocate_sync(nullptr, 0);
+  mr.deallocate_sync(nullptr, 0, rmm::CUDA_ALLOCATION_ALIGNMENT);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/tests/mr/binning_mr_tests.cpp` around lines 31 - 43, The test calls
binning_mr::deallocate with an alignment but calls binning_mr::deallocate_sync
without it; update the test (BinningTest::ZeroByteDeallocateIsNoOp) to pass the
alignment to deallocate_sync as well (use the same
rmm::CUDA_ALLOCATION_ALIGNMENT constant) so the call matches the
deallocate_sync(ptr, bytes, alignment) signature in binning_mr and keeps
behavior consistent with deallocate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cpp/tests/mr/binning_mr_tests.cpp`:
- Around line 31-43: The test calls binning_mr::deallocate with an alignment but
calls binning_mr::deallocate_sync without it; update the test
(BinningTest::ZeroByteDeallocateIsNoOp) to pass the alignment to deallocate_sync
as well (use the same rmm::CUDA_ALLOCATION_ALIGNMENT constant) so the call
matches the deallocate_sync(ptr, bytes, alignment) signature in binning_mr and
keeps behavior consistent with deallocate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: aa45d400-c99e-45f7-9942-f4922782d7cb

📥 Commits

Reviewing files that changed from the base of the PR and between b187020 and 15260ac.

📒 Files selected for processing (2)
  • cpp/src/mr/detail/binning_memory_resource_impl.cpp
  • cpp/tests/mr/binning_mr_tests.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking Non-breaking change

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant