Reduce the overhead when cache is disabled (#1010)

This commit is contained in:
Liangsheng Yin
2024-08-09 16:36:57 -07:00
committed by GitHub
parent 73fa2d49d5
commit 62757db6f0
4 changed files with 35 additions and 43 deletions

View File

@@ -169,6 +169,9 @@ class RadixCache(BasePrefixCache):
heapq.heappush(leaves, x.parent)
def inc_lock_ref(self, node: TreeNode):
if self.disable:
return 0
delta = 0
while node != self.root_node:
if node.lock_ref == 0:
@@ -179,6 +182,9 @@ class RadixCache(BasePrefixCache):
return delta
def dec_lock_ref(self, node: TreeNode):
if self.disable:
return 0
delta = 0
while node != self.root_node:
if node.lock_ref == 1: