Skip to content

fix: pinned models no longer block LRU eviction#2091

Merged
hansent merged 3 commits intomainfrom
fix/pinned-model-eviction-loop
Mar 10, 2026
Merged

fix: pinned models no longer block LRU eviction#2091
hansent merged 3 commits intomainfrom
fix/pinned-model-eviction-loop

Conversation

@hansent
Copy link
Collaborator

@hansent hansent commented Mar 6, 2026

Summary

  • Fixes a bug where pinned models at the front of the LRU queue consumed eviction loop iterations without evicting anything
  • With 3+ pinned models as LRU, for _ in range(3) would exhaust all iterations skipping pinned models, causing the cache to silently overflow
  • Switches to while evicted_count < 3 and self._key_queue: so only actual evictions count toward the limit

Related: #2048 (pinned models feature)

Test plan

  • Verify with 3+ pinned models as LRU that non-pinned models are correctly evicted when cache is full
  • Verify pinned models remain loaded and in queue after eviction pass
  • Verify behavior unchanged when no models are pinned

🤖 Generated with Claude Code

The eviction loop used `for _ in range(3)`, so pinned models at the
front of the queue consumed loop iterations without actually evicting
anything. With 3+ pinned models as LRU, no eviction would occur and
the cache would silently overflow. Switch to a while loop that only
counts actual evictions toward the limit of 3.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hansent hansent force-pushed the fix/pinned-model-eviction-loop branch from f863e40 to 29a3600 Compare March 6, 2026 22:08
@hansent hansent merged commit 43153d3 into main Mar 10, 2026
55 of 60 checks passed
@hansent hansent deleted the fix/pinned-model-eviction-loop branch March 10, 2026 15:05
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.

3 participants