refactor(memory-pool): drain the table in cleanup_all instead of cloning keys - #2840
Merged
trunk-io[bot] merged 1 commit intoJul 28, 2026
Merged
Conversation
…ing keys `cleanup_all` collected every `MemoryPoolId` key into a throwaway `Vec` (cloning two `String`s per entry) only to look each id back up and `remove` it one at a time. Replace that with a single `std::mem::take(&mut *table)` move and iterate the drained map directly. Behavior is unchanged: the guard is still held for the whole function (`free_shared_memory` never re-enters the table, so this can't deadlock), the table still ends empty, and the `unreleased_count` / `released_count` accounting is identical. This change is machine-generated by Claude (an AI assistant) as part of an automated code-review run, and reviewed against current origin/main. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TMv79fayzGF9mDV7vPMQN7
Contributor
|
😎 Merged successfully - details. |
Collaborator
Author
|
🤖 Automated review by Claude — fully automated, no human in the loop. The Generated by Claude Code |
phil-opp
marked this pull request as ready for review
July 28, 2026 10:42
trunk-io
Bot
deleted the
claude/dreamy-bardeen-0efkxi-memory-pool-cleanup
branch
July 28, 2026 11:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
MemoryPoolManager::cleanup_allcollected everyMemoryPoolIdkey into a throwawayVec(cloning twoStrings per entry) only to look each id back up andremoveit one at a time:Fix
Replace that with a single
std::mem::take(&mut *table)move and iterate the drained map directly, dropping the key clones and the redundant per-id re-lookup.Behavior is unchanged:
free_shared_memorynever re-enters the table, so this can't deadlock — the original relied on the same fact);unreleased_count/released_countaccounting is identical.Validation
cargo clippy -p dora-memory-pool --all-targets -- -D warningsclean.cargo test -p dora-memory-pool --lib→ 9 passed, includingcleanup_all_tracks_countsandcleanup_all_reports_partial_release_on_failure.origin/main. Please review carefully before merging.🤖 Generated with Claude Code
https://claude.ai/code/session_01TMv79fayzGF9mDV7vPMQN7
Generated by Claude Code