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

Add release_unused function to memory pools. #4556

Merged
merged 2 commits into from
Jan 11, 2023

Conversation

mzient
Copy link
Contributor

@mzient mzient commented Jan 9, 2023

Signed-off-by: Michal Zientkiewicz michalz@nvidia.com

Category:

New feature (non-breaking change which adds functionality)

Description:

As per user-request, this adds the functionality necessary to implement memory "garbage collection".
Internally, there are three implementations:

  1. Regular pool: go over blocks and free any that are completely covered by free regions. This was already used by the pool to reclaim memory and now has just been exposed.
  2. Async pool - frees all pending per-stream free blocks to the global pool and then calls release_unused on it.
  3. CUDA VM resource - goes over all available blocks in all regions and frees them, releasing the physical blocks and removing them from free_mapped. The virtual address space is not a concern and is never freed.

The relevant changes in public APIs are not in the scope of this PR - it just implements the underlying functionality

Additional information:

Affected modules and functionalities:

Key points relevant for the review:

Tests:

Existing pool tests were extended by inserting a call to release_unused halfway through the test.
cuda_vm_resource received a new test, since this functionality is otherwise not tested, whereas other a regular pool may use release_unused_impl to reclaim memory before allocating a new block from upstream..

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: DALI-3170

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6967204]: BUILD STARTED

@JanuszL JanuszL self-assigned this Jan 9, 2023
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [6967204]: BUILD PASSED

@mzient mzient merged commit 4890d5d into NVIDIA:main Jan 11, 2023
aderylo pushed a commit to zpp-dali-2022/DALI that referenced this pull request Mar 17, 2023
Add release_unused function to memory pools. The function frees memory that's not currently in use and can be safely freed.
* Generic pool: release only complete blocks allocated from the upstream
* CUDA VM resource: release all blocks that are fully available
* Async pool - collect per-stream free blocks first, then release_upstream on the global pool.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@JanuszL JanuszL mentioned this pull request Sep 6, 2023
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.

4 participants