Skip to content

feat: add max_evict parameter to limit evictions per try_evict call#35

Merged
SF-Zhou merged 2 commits into
mainfrom
dev
Apr 27, 2026
Merged

feat: add max_evict parameter to limit evictions per try_evict call#35
SF-Zhou merged 2 commits into
mainfrom
dev

Conversation

@SF-Zhou

@SF-Zhou SF-Zhou commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add max_evict parameter to limit the number of entries evicted per try_evict call
  • Defaults to usize::MAX, fully backward compatible with existing behavior
  • Add set_max_evict() public API; a value of 0 is coerced to 1
  • Includes 5 unit tests covering various edge cases

Co-Authored-By: DeepSeek V4 Pro noreply@deepseek.com

Copilot AI review requested due to automatic review settings April 27, 2026 07:16
@codecov

codecov Bot commented Apr 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b407654) to head (467f491).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #35   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines         1533      1609   +76     
=========================================
+ Hits          1533      1609   +76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Adds a per-shard max_evict field (default usize::MAX) that bounds the
number of entries evicted in a single try_evict call. A set_max_evict()
public API is added, with 0 treated as 1 for safety.

Co-Authored-By: DeepSeek V4 Pro <noreply@deepseek.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a per-try_evict eviction cap to LruLockMap, allowing callers to limit how many entries can be evicted during a single eviction pass while preserving the existing default behavior (unlimited).

Changes:

  • Added a max_evict limit to each shard and enforced it inside LruShardInner::try_evict.
  • Introduced a new public API LruLockMap::set_max_evict() to configure the limit across all shards.
  • Added unit tests covering default behavior, limited eviction, zero handling, in-use entries, and capacity shrinking scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lru_lockmap.rs
Comment thread src/lru_lockmap.rs Outdated
Co-Authored-By: DeepSeek V4 Pro <noreply@deepseek.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SF-Zhou SF-Zhou merged commit ed6d229 into main Apr 27, 2026
16 checks passed
@SF-Zhou SF-Zhou deleted the dev branch April 27, 2026 07:54
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