Repository navigation
fix: disable_auto_manage! clears pending requests - #48
Merged
Merged
Conversation
disable_auto_manage! only closed the Timer, leaving each pool's _compact_requested / _trim_requested flags set. A flag set by the last sweep before disable would then trigger one more compaction/trim cycle at the next @with_pool entry — an unexpected allocation after the user explicitly turned auto-manage off. Clear all live pools' flags (and reset the trim tick) in the timer-stop chokepoint, under _AUTO_MANAGE_LOCK so stop-and-clear is atomic against a concurrent sweep. Add a regression test.
There was a problem hiding this comment.
Pull request overview
This PR fixes a runtime behavior in AdaptiveArrayPools’ auto-manage system where disable_auto_manage!() stopped the background Timer but could leave _compact_requested / _trim_requested flags set from the last sweep, causing one unexpected post-disable maintenance run at the next @with_pool entry.
Changes:
- Add an internal helper to clear all pending auto-manage request flags across the live pool registry and reset the trim tick cadence.
- Invoke this clearing step in the timer-stop path (
_stop_auto_manage_timer_unlocked!) under_AUTO_MANAGE_LOCKto make stopping + clearing atomic vs concurrent sweeps. - Add a regression test ensuring disabling drops pending requests and
_maybe_auto_manage!becomes a no-op post-disable.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/auto_manage.jl |
Clears pending compaction/trim requests (and resets trim cadence) when stopping the auto-manage timer to prevent post-disable maintenance. |
test/test_auto_manage.jl |
Adds regression coverage that a pre-disable sweep request cannot trigger a post-disable auto-manage run. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #48 +/- ##
==========================================
+ Coverage 95.81% 95.82% +0.01%
==========================================
Files 16 16
Lines 3607 3619 +12
==========================================
+ Hits 3456 3468 +12
Misses 151 151
🚀 New features to boost your workflow:
|
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.
Summary
Problem.
The Timer sweep only sets each pool's
_compact_requested/_trim_requestedflags; pools service them later at a@with_poolentry.disable_auto_manage!()closed the Timer but left the flags set — so a flag from the last pre-disable sweep triggered one more compaction/trim after auto-manage was explicitly turned off (an unexpected allocation, not a corruption: it runs at then_active == 0safepoint, try/catch-wrapped).Fix.
Clear all live pools' flags + reset the trim tick in the timer-stop chokepoint (
_stop_auto_manage_timer_unlocked!), under_AUTO_MANAGE_LOCKso stop-and-clear is atomic against a concurrent sweep. Backend-agnostic (host-side atomic Bool; GPU pools share the same registry/Timer) and off the hot path — runs only at disable/enable/exit. Legacy path (< 1.12) is a no-op shim, unaffected.Test.
Regression: sweep a bloated pool → disable → assert flag cleared and a later
_maybe_auto_manage!no-ops. Full suite passes;src/auto_manage.jl100% line coverage.