[Bugfix][fast] Fix the get_num_blocks_touched logic (#6849)
This commit is contained in:
@@ -307,9 +307,8 @@ class NaiveBlockAllocator(BlockAllocator):
|
||||
# TODO(cade): make sure the logic is correct and clean it up.
|
||||
for block in blocks:
|
||||
if not block.is_full and num_lookahead_slots != 0:
|
||||
if block.num_empty_slots >= num_lookahead_slots:
|
||||
new_block_count += 1
|
||||
else:
|
||||
new_block_count += 1
|
||||
if num_lookahead_slots > block.num_empty_slots:
|
||||
new_block_count += cdiv(
|
||||
num_lookahead_slots - block.num_empty_slots,
|
||||
self._block_size)
|
||||
|
||||
@@ -579,14 +579,17 @@ class PrefixCachingBlockAllocator(BlockAllocator):
|
||||
num_touched_blocks = 0
|
||||
for block in blocks:
|
||||
if not block.is_full:
|
||||
if block.num_empty_slots >= num_lookahead_slots:
|
||||
num_touched_blocks += 1
|
||||
else:
|
||||
num_touched_blocks += 1
|
||||
if num_lookahead_slots > block.num_empty_slots:
|
||||
num_touched_blocks += cdiv(
|
||||
num_lookahead_slots - block.num_empty_slots,
|
||||
self._block_size)
|
||||
else:
|
||||
if not self.is_block_cached(block):
|
||||
# If the block has a match in the cache and the cached block
|
||||
# is not referenced, then we still count it as a touched block
|
||||
if not self.is_block_cached(block) or \
|
||||
(block.content_hash is not None and \
|
||||
self._cached_blocks[block.content_hash] in self.evictor):
|
||||
num_touched_blocks += 1
|
||||
return num_touched_blocks
|
||||
|
||||
|
||||
Reference in New Issue
Block a user