[Core] Reuse empty block lists whenever possible in KVCacheBlocks to mitigate GC costs (#24964)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
This commit is contained in:
Jialin Ouyang
2025-10-14 12:58:43 -07:00
committed by GitHub
parent 82af928c41
commit acaa2c0a4a
5 changed files with 53 additions and 26 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from collections.abc import Iterable
from collections.abc import Iterable, Sequence
from typing import Any
from vllm.distributed.kv_events import (
@@ -328,7 +328,7 @@ class BlockPool:
)
return True
def touch(self, blocks: tuple[list[KVCacheBlock], ...]) -> None:
def touch(self, blocks: tuple[Sequence[KVCacheBlock], ...]) -> None:
"""Touch a block increases its reference count by 1, and may remove
the block from the free queue. This is used when a block is hit by
another request with the same prefix.