[Refactor][kv_offload]: rename block→chunk (#52615)

Signed-off-by: Ronen Schaffer <ronen.schaffer@ibm.com>
This commit is contained in:
Ronen Schaffer
2026-09-09 17:45:49 +03:00
committed by GitHub
parent 9ffb8cea96
commit 138d137b5b
34 changed files with 933 additions and 916 deletions
+22 -22
View File
@@ -3,7 +3,7 @@
"""
ExampleSecondaryTierManager: A simple in-memory secondary tier.
This implementation provides a minimal secondary tier that stores blocks
This implementation provides a minimal secondary tier that stores chunks
in memory (using a dictionary) with immediate completion. It serves as a
reference for writing new tiers and is useful for testing the
TieringOffloadingManager without requiring actual storage or network backends.
@@ -39,7 +39,7 @@ class ExampleSecondaryTierManager(SecondaryTierManager):
A simple in-memory secondary tier.
This implementation:
- Stores blocks in a dictionary (key -> True)
- Stores chunks in a dictionary (key -> True)
- Completes transfers immediately (synchronous)
"""
@@ -69,45 +69,45 @@ class ExampleSecondaryTierManager(SecondaryTierManager):
)
# key -> True (only care about presence)
self.blocks: dict[OffloadKey, bool] = {}
self.chunks: dict[OffloadKey, bool] = {}
# Completed jobs waiting to be retrieved by get_finished_jobs()
self.completed_jobs: list[JobResult] = []
assert primary_kv_view.strides is not None
self._block_size = primary_kv_view.strides[0]
self._chunk_size = primary_kv_view.strides[0]
@override
def lookup(self, key: OffloadKey, req_context: ReqContext) -> LookupResult:
"""
Check whether a block exists in this secondary tier.
Check whether a chunk exists in this secondary tier.
Args:
key: Offload key to look up.
req_context: Per-request context.
Returns:
HIT if the block is present, MISS if not found.
HIT if the chunk is present, MISS if not found.
"""
return LookupResult.HIT if key in self.blocks else LookupResult.MISS
return LookupResult.HIT if key in self.chunks else LookupResult.MISS
@override
def submit_store(self, job_metadata: TransferJob) -> None:
"""
Submit a job to store blocks from primary tier to this tier.
Submit a job to store chunks from primary tier to this tier.
Args:
job_metadata: Job metadata including job_id, keys, and
spec for reading blocks from the primary tier.
spec for reading chunks from the primary tier.
"""
keys = job_metadata.keys
block_ids = job_metadata.block_ids
chunk_ids = job_metadata.chunk_ids
assert len(keys) == len(block_ids), (
f"Length mismatch: {len(keys)} keys but {len(block_ids)} block_ids"
assert len(keys) == len(chunk_ids), (
f"Length mismatch: {len(keys)} keys but {len(chunk_ids)} chunk_ids"
)
for key in keys:
self.blocks[key] = True
self.chunks[key] = True
self.completed_jobs.append(
JobResult(
job_id=job_metadata.job_id,
@@ -119,21 +119,21 @@ class ExampleSecondaryTierManager(SecondaryTierManager):
@override
def submit_load(self, job_metadata: TransferJob) -> None:
"""
Submit a job to load blocks from this tier to primary tier.
Submit a job to load chunks from this tier to primary tier.
Args:
job_metadata: Job metadata including job_id, keys, and
spec for writing blocks into the primary tier.
spec for writing chunks into the primary tier.
"""
keys = job_metadata.keys
block_ids = job_metadata.block_ids
chunk_ids = job_metadata.chunk_ids
assert len(keys) == len(block_ids), (
f"Length mismatch: {len(keys)} keys but {len(block_ids)} block_ids"
assert len(keys) == len(chunk_ids), (
f"Length mismatch: {len(keys)} keys but {len(chunk_ids)} chunk_ids"
)
for key in keys:
if key not in self.blocks:
if key not in self.chunks:
self.completed_jobs.append(
JobResult(job_id=job_metadata.job_id, success=False)
)
@@ -170,6 +170,6 @@ class ExampleSecondaryTierManager(SecondaryTierManager):
completes, so there is nothing to wait for."""
return
def get_num_blocks(self) -> int:
"""Get the number of blocks currently stored in this tier."""
return len(self.blocks)
def get_num_chunks(self) -> int:
"""Get the number of chunks currently stored in this tier."""
return len(self.chunks)