Skip to content

fix: disable_auto_manage! clears pending requests - #48

Merged
mgyoo86 merged 1 commit into
masterfrom
fix/auto-manage-disable-clears-pending
Jul 1, 2026
Merged

mgyoo86 merged 1 commit into
masterfrom
fix/auto-manage-disable-clears-pending

Conversation

@mgyoo86

@mgyoo86 mgyoo86 commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

Problem.

The Timer sweep only sets each pool's _compact_requested/_trim_requested flags; pools service them later at a @with_pool entry. 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 the n_active == 0 safepoint, 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_LOCK so 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.jl 100% line coverage.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_LOCK to 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

codecov Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.82%. Comparing base (f8fa236) to head (c6abf14).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            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              
Files with missing lines Coverage Δ
src/auto_manage.jl 98.05% <100.00%> (+0.25%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mgyoo86
mgyoo86 merged commit bcb69ae into master Jul 1, 2026
15 checks passed
@mgyoo86
mgyoo86 deleted the fix/auto-manage-disable-clears-pending branch July 1, 2026 18:28
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.

2 participants