[kv_offload] Implement reset_cache() for the offloading connector (#41956)

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Or Ozeri <or@ozery.com>
This commit is contained in:
Martin Hickey
2026-05-14 16:00:10 +03:00
committed by GitHub
co-authored by gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Or Ozeri
parent 6548560496
commit 5bd8c71e79
8 changed files with 153 additions and 0 deletions
+4
View File
@@ -218,6 +218,10 @@ class OffloadingManager(ABC):
"""
return ()
def reset_cache(self) -> None:
"""Evict all tracked blocks and reset internal state."""
return
def shutdown(self) -> None:
"""Shutdown the manager and release any resources."""
return
+11
View File
@@ -223,6 +223,17 @@ class CPUOffloadingManager(OffloadingManager):
)
)
def reset_cache(self) -> None:
# Clear ALL blocks unconditionally. The scheduler's _stale_job_threshold
# guarantees that complete_load / complete_store are never called for
# pre-reset jobs, so no lazy cleanup is needed. The scheduler also
# flushes in-flight load job IDs to the workers before any new stores
# can begin, preventing a cross-direction data race on reused offload block IDs.
self._policy.clear()
self._free_list.clear()
self._num_allocated_blocks = 0
def take_events(self) -> Iterable[OffloadingEvent]:
if self.events is not None:
yield from self.events
+7
View File
@@ -94,6 +94,13 @@ class ARCCachePolicy(CachePolicy):
# move to MRU position (end) to keep it fresh in the ghost list
self.b2.move_to_end(key)
def clear(self) -> None:
self.t1.clear()
self.t2.clear()
self.b1.clear()
self.b2.clear()
self.target_t1_size = 0.0
def evict(
self, n: int, protected: set[OffloadKey]
) -> list[tuple[OffloadKey, BlockStatus]] | None:
+8
View File
@@ -74,3 +74,11 @@ class CachePolicy(ABC):
For ARC: ghost list cleanup (trimming to cache_capacity) is performed
at the end of a successful eviction.
"""
@abstractmethod
def clear(self) -> None:
"""
Remove ALL blocks regardless of ref_cnt.
Ghost lists and adaptive state are also reset.
"""
+3
View File
@@ -28,6 +28,9 @@ class LRUCachePolicy(CachePolicy):
if key in self.blocks:
self.blocks.move_to_end(key)
def clear(self) -> None:
self.blocks.clear()
def evict(
self, n: int, protected: set[OffloadKey]
) -> list[tuple[OffloadKey, BlockStatus]] | None: