Xuanwo opened a new pull request, #8883:
URL: https://github.com/apache/opendal/pull/8883

   # Which issue does this PR close?
   
   Part of #7107.
   
   # Rationale for this change
   
   `FoyerCore` retained every deleted key indefinitely in an unbounded 
`HashSet<FoyerKey>` behind a global `std::sync::Mutex`. When `services::Foyer` 
backs `CacheLayer` (or any workload with frequent deletes/invalidations), 
deleted keys accumulate in memory without bound, and every concurrent `get` 
serializes on the global mutex even when no tombstones exist.
   
   # What changes are included in this PR?
   
   - Replace the unbounded `Mutex<HashSet<FoyerKey>>` in `FoyerCore` with a 
FIFO-bounded `DeletedKeys` table (`MAX_DELETED_KEYS = 1024`, matching 
`layers/foyer` #8819) behind `RwLock`, re-issuing `cache.remove` for evicted 
tombstones.
   - Track active tombstone count with an `AtomicUsize` so `get` and `insert` 
skip locking completely when no tombstones are present, and look up keys by 
`&str` via `Arc<str>` without allocating a `FoyerKey` on tombstone hits.
   - Record tombstones before calling `cache.remove` so a concurrent `insert` 
cannot miss the tombstone cleanup check.
   - Add unit tests covering FIFO tombstone eviction, recency refresh, bounded 
growth, and delete/re-insert visibility.
   
   # Are there any user-facing changes?
   
   `services::Foyer` no longer leaks memory under repeated deletes and avoids 
global mutex contention on concurrent reads. No public API changes.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: Pi (T3 Code)
   - Model: Gemini 4 Neon
   - Effort: high
   - Role: Identified the unbounded tombstone set and mutex contention while 
auditing `CacheLayer` + `services::Foyer`, implemented the bounded `RwLock` 
tombstone table and unit tests, and ran formatting, clippy, and 
`opendal-service-foyer` tests.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to