Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/sglang/srt/mem_cache/hicache_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import torch

from python.sglang.srt.metrics.collector import StorageMetrics
from sglang.srt.mem_cache.memory_pool_host import HostKVCache

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -162,7 +163,7 @@ def batch_exists(
def clear(self) -> None:
pass

def get_stats(self):
def get_stats(self) -> Optional[StorageMetrics]:
return None


Expand Down
30 changes: 18 additions & 12 deletions python/sglang/srt/mem_cache/storage/hf3fs/storage_hf3fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,18 +486,24 @@ def close(self) -> None:
logger.error(f"close HiCacheHF3FS: {e}")
logger.info("close HiCacheHF3FS")

@synchronized()
def get_stats(self):
storage_metrics = StorageMetrics()
storage_metrics.prefetch_pgs.extend(self.prefetch_pgs)
storage_metrics.backup_pgs.extend(self.backup_pgs)
storage_metrics.prefetch_bandwidth.extend(self.prefetch_bandwidth)
storage_metrics.backup_bandwidth.extend(self.backup_bandwidth)
self.prefetch_pgs.clear()
self.backup_pgs.clear()
self.prefetch_bandwidth.clear()
self.backup_bandwidth.clear()
return storage_metrics
def get_stats(self) -> Optional[StorageMetrics]:
# Acquire lock without blocking
if not self.lock.acquire(blocking=False):
return None

try:
storage_metrics = StorageMetrics()
storage_metrics.prefetch_pgs.extend(self.prefetch_pgs)
storage_metrics.backup_pgs.extend(self.backup_pgs)
storage_metrics.prefetch_bandwidth.extend(self.prefetch_bandwidth)
storage_metrics.backup_bandwidth.extend(self.backup_bandwidth)
self.prefetch_pgs.clear()
self.backup_pgs.clear()
self.prefetch_bandwidth.clear()
self.backup_bandwidth.clear()
return storage_metrics
finally:
self.lock.release()

def register_mem_pool_host(self, mem_pool_host: HostKVCache):
super().register_mem_pool_host(mem_pool_host)
Expand Down
Loading