[KV Connector][Offloading] Avoid blocking the engine to flush offloads on idle (#45595)
Signed-off-by: Itay Etelis <itay.etelis@ibm.com> Signed-off-by: Or Ozeri <oro@il.ibm.com> Signed-off-by: Itay Etelis <Itay.etelis@gmail.com> Co-authored-by: Itay Etelis <itay.etelis@ibm.com> Co-authored-by: Or Ozeri <oro@il.ibm.com> Co-authored-by: Itay Etelis <Itay.etelis@gmail.com>
This commit is contained in:
co-authored by
Itay Etelis
Or Ozeri
Itay Etelis
parent
e2c58570ea
commit
6d8fff5698
@@ -1016,14 +1016,6 @@ class OffloadingConnectorScheduler:
|
||||
for jid in self._block_id_to_pending_jobs[bid]
|
||||
)
|
||||
|
||||
# If all tracked requests are finished, flush all pending jobs
|
||||
# (both store and load) - there might not be a future scheduler
|
||||
# step to trigger their completion.
|
||||
if self._req_status and all(
|
||||
rs.req.is_finished() for rs in self._req_status.values()
|
||||
):
|
||||
self._current_batch_jobs_to_flush.update(self._jobs.keys())
|
||||
|
||||
meta = OffloadingConnectorMetadata(
|
||||
load_jobs=self._current_batch_load_jobs,
|
||||
store_jobs=self._build_store_jobs(scheduler_output),
|
||||
@@ -1034,6 +1026,14 @@ class OffloadingConnectorScheduler:
|
||||
self._current_batch_allocated_block_ids = set()
|
||||
return meta
|
||||
|
||||
def has_pending_push_work(self) -> bool:
|
||||
"""Whether the engine must keep stepping.
|
||||
|
||||
While True, build_connector_meta() and update_connector_output()
|
||||
continue to be called even when no requests are scheduled.
|
||||
"""
|
||||
return bool(self._jobs) or self.manager.has_pending_work()
|
||||
|
||||
def update_connector_output(self, connector_output: KVConnectorOutput):
|
||||
"""
|
||||
Update KVConnector state from worker-side connectors output.
|
||||
|
||||
@@ -150,6 +150,10 @@ class OffloadingConnector(KVConnectorBase_V1, SupportsHMA):
|
||||
assert self.connector_scheduler is not None
|
||||
return self.connector_scheduler.build_connector_meta(scheduler_output)
|
||||
|
||||
def has_pending_push_work(self) -> bool:
|
||||
assert self.connector_scheduler is not None
|
||||
return self.connector_scheduler.has_pending_push_work()
|
||||
|
||||
def update_connector_output(self, connector_output: KVConnectorOutput):
|
||||
assert self.connector_scheduler is not None
|
||||
self.connector_scheduler.update_connector_output(connector_output)
|
||||
|
||||
@@ -288,6 +288,14 @@ class OffloadingManager(ABC):
|
||||
"""
|
||||
return
|
||||
|
||||
def has_pending_work(self) -> bool:
|
||||
"""Whether this manager needs the engine to keep stepping.
|
||||
|
||||
While True, on_schedule_end() and get_finished_jobs() continue
|
||||
to be called even when no requests are scheduled.
|
||||
"""
|
||||
return False
|
||||
|
||||
def reset_cache(self) -> None:
|
||||
"""Evict all tracked blocks and reset internal state."""
|
||||
return
|
||||
|
||||
@@ -153,6 +153,14 @@ class SecondaryTierManager(ABC):
|
||||
"""
|
||||
pass
|
||||
|
||||
def has_pending_work(self) -> bool:
|
||||
"""Whether this tier needs the engine to keep stepping.
|
||||
|
||||
While True, on_schedule_end() and get_finished_jobs() continue
|
||||
to be called even when no requests are scheduled.
|
||||
"""
|
||||
return False
|
||||
|
||||
def touch(self, keys: Collection[OffloadKey], req_context: ReqContext):
|
||||
"""
|
||||
Mark blocks as recently used for eviction policy.
|
||||
|
||||
@@ -577,6 +577,15 @@ class TieringOffloadingManager(OffloadingManager):
|
||||
for tier in self.secondary_tiers:
|
||||
tier.on_schedule_end()
|
||||
|
||||
@override
|
||||
def has_pending_work(self) -> bool:
|
||||
# In-flight primary<->secondary transfers (pending promotions are
|
||||
# translated to transfer jobs in on_schedule_end), plus any work the
|
||||
# secondary tiers themselves still have outstanding.
|
||||
return bool(self._transfer_jobs) or any(
|
||||
tier.has_pending_work() for tier in self.secondary_tiers
|
||||
)
|
||||
|
||||
@override
|
||||
def take_events(self) -> Iterable[OffloadingEvent]:
|
||||
"""Yield offloading events collected since the last call.
|
||||
|
||||
Reference in New Issue
Block a user