mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-18 22:42:35 +08:00
caching: add set_local implementation for LRU and RAM pressure
This commit is contained in:
parent
56fe08648c
commit
7a0fb40daa
@ -475,6 +475,10 @@ class LRUCache(BasicCache):
|
|||||||
self._mark_used(node_id)
|
self._mark_used(node_id)
|
||||||
return await self._set_immediate(node_id, value)
|
return await self._set_immediate(node_id, value)
|
||||||
|
|
||||||
|
def set_local(self, node_id, value):
|
||||||
|
self._mark_used(node_id)
|
||||||
|
BasicCache.set_local(self, node_id, value)
|
||||||
|
|
||||||
async def ensure_subcache_for(self, node_id, children_ids):
|
async def ensure_subcache_for(self, node_id, children_ids):
|
||||||
# Just uses subcaches for tracking 'live' nodes
|
# Just uses subcaches for tracking 'live' nodes
|
||||||
await super()._ensure_subcache(node_id, children_ids)
|
await super()._ensure_subcache(node_id, children_ids)
|
||||||
@ -521,6 +525,10 @@ class RAMPressureCache(LRUCache):
|
|||||||
self.timestamps[self.cache_key_set.get_data_key(node_id)] = time.time()
|
self.timestamps[self.cache_key_set.get_data_key(node_id)] = time.time()
|
||||||
return await super().get(node_id)
|
return await super().get(node_id)
|
||||||
|
|
||||||
|
def set_local(self, node_id, value):
|
||||||
|
self.timestamps[self.cache_key_set.get_data_key(node_id)] = time.time()
|
||||||
|
super().set_local(node_id, value)
|
||||||
|
|
||||||
def poll(self, ram_headroom):
|
def poll(self, ram_headroom):
|
||||||
def _ram_gb():
|
def _ram_gb():
|
||||||
return psutil.virtual_memory().available / (1024**3)
|
return psutil.virtual_memory().available / (1024**3)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user