[Bugfix][NIXL] Don't evict a remote engine a transfer is still reading from (#54689)
Signed-off-by: Yizheng Jiao <jyizheng@gmail.com>
This commit is contained in:
@@ -3143,7 +3143,9 @@ class NixlBaseConnectorWorker:
|
||||
to be "optimal" until a new handshake is performed.
|
||||
|
||||
Engines with active transfers or pending handshakes cannot be stale:
|
||||
- Active transfers touch _engine_last_active in start_load_kv.
|
||||
- Reads stamp _engine_last_active when they are issued, and engines a
|
||||
transfer is still reading from are held back explicitly, since the
|
||||
stamp is not refreshed while the read runs.
|
||||
- Pending handshakes don't have an _engine_last_active entry yet
|
||||
"""
|
||||
# NOTE (NickLucche): This does NOT currently prevent OOMing if a huge number
|
||||
@@ -3154,10 +3156,25 @@ class NixlBaseConnectorWorker:
|
||||
return
|
||||
|
||||
now = time.perf_counter()
|
||||
busy = self._engines_with_inflight_transfers()
|
||||
for eid, last_active in list(self._engine_last_active.items()):
|
||||
if now - last_active > self._engine_ttl:
|
||||
if now - last_active > self._engine_ttl and eid not in busy:
|
||||
self._cleanup_remote_engine(eid)
|
||||
|
||||
def _engines_with_inflight_transfers(self) -> set[EngineId]:
|
||||
"""Remote engines a transfer is still reading from.
|
||||
|
||||
The timestamp is stamped when a read is issued and not refreshed while
|
||||
it runs, so a transfer that outlives the TTL leaves its engine looking
|
||||
idle. A peer that has lost its NIC holds one indefinitely.
|
||||
"""
|
||||
return {
|
||||
meta.remote.engine_id
|
||||
for req_id in self._recving_transfers
|
||||
if (meta := self._recving_metadata.get(req_id)) is not None
|
||||
and meta.remote is not None
|
||||
}
|
||||
|
||||
def _cleanup_remote_engine(
|
||||
self, engine_id: EngineId, *, log_eviction: bool = True
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user