Repository navigation
feat: surface paged KV block budget in cache stats and metrics - #178
Merged
Merged
Conversation
Sub-step c — the final piece of #122 (Phase 5 block-budget admission / eviction / preemption). With b1/b2/b3 the paged KV pool now admits, evicts, and preempts against a configurable block budget; this exposes that state to operators so they can observe admission headroom and eviction under pressure. `GET /v1/cache/stats` gains seven paged block-pool fields (block_size, blocks_allocated/live/free, bytes_reserved/in_use, and block_budget), sourced from the batch observability snapshot rather than the prompt-cache store so they stay meaningful even when the prompt cache is disabled — paged decode runs independently. `paged_block_budget` is the configured cap (0 = unbounded), so `paged_block_budget - paged_blocks_live` is the acquirable headroom before eviction / preemption kicks in. The block-budget cap was the one paged datum not already a gauge, so a `cache_pool_paged_block_budget` gauge is added through BatchObservability (recorded each scheduler tick from `CachePool::paged_block_budget`) and exposed as `mlxcel_cache_pool_paged_block_budget` on `/metrics`; the allocated/live/free block and byte gauges already existed. Tests cover the new data path end to end: observability records the budget, `PagedBlockStats::from_observability` projects the snapshot, and `build_stats_response` propagates the paged fields on both the store-present and store-absent branches. The admit-under-pressure / no-leak behaviour is already covered by the b2 eviction test (`evicting_cold_prefix_restores_paged_block_budget`). This completes every task and acceptance criterion on #122. Closes #122.
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
…p#178) Sub-step c — the final piece of lablup#122 (Phase 5 block-budget admission / eviction / preemption). With b1/b2/b3 the paged KV pool now admits, evicts, and preempts against a configurable block budget; this exposes that state to operators so they can observe admission headroom and eviction under pressure. `GET /v1/cache/stats` gains seven paged block-pool fields (block_size, blocks_allocated/live/free, bytes_reserved/in_use, and block_budget), sourced from the batch observability snapshot rather than the prompt-cache store so they stay meaningful even when the prompt cache is disabled — paged decode runs independently. `paged_block_budget` is the configured cap (0 = unbounded), so `paged_block_budget - paged_blocks_live` is the acquirable headroom before eviction / preemption kicks in. The block-budget cap was the one paged datum not already a gauge, so a `cache_pool_paged_block_budget` gauge is added through BatchObservability (recorded each scheduler tick from `CachePool::paged_block_budget`) and exposed as `mlxcel_cache_pool_paged_block_budget` on `/metrics`; the allocated/live/free block and byte gauges already existed. Tests cover the new data path end to end: observability records the budget, `PagedBlockStats::from_observability` projects the snapshot, and `build_stats_response` propagates the paged fields on both the store-present and store-absent branches. The admit-under-pressure / no-leak behaviour is already covered by the b2 eviction test (`evicting_cold_prefix_restores_paged_block_budget`). This completes every task and acceptance criterion on lablup#122. Closes lablup#122.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sub-step c — the final piece of #122 (Phase 5: block-budget admission, eviction, preemption). b1/b2/b3 built the budget mechanism + activation; this surfaces the pool's block-level usage so operators can observe admission headroom and eviction under pressure.
What changed
GET /v1/cache/statsgains seven paged block-pool fields:paged_block_size0= no paged pool)paged_blocks_allocatedpaged_blocks_livepaged_blocks_freepaged_bytes_reserved/paged_bytes_in_usepaged_block_budget0= unbounded)Sourced from the batch observability snapshot (not the prompt-cache store), so they stay meaningful even with the prompt cache disabled — paged decode runs independently.
paged_block_budget - paged_blocks_liveis the acquirable headroom before eviction / preemption./metricsgainsmlxcel_cache_pool_paged_block_budget— the one paged datum that wasn't already a gauge. Added throughBatchObservability(recorded each scheduler tick fromCachePool::paged_block_budget); the allocated / live / free block + byte gauges already existed.#122 completion
/v1/cache/stats+ PrometheusTest plan
cargo build+ coldcargo clippy -D warnings+cargo fmt --all --check— cleancargo test: routes::cache 17 (3 new), batch::observability 6 (budget assertion), batch::scheduler_prompt_cache 21, server::batch 181, prompt_cache::apc_integration 9 — all greenbuild_stats_response_surfaces_paged_pool_independent_of_store,paged_block_stats_projects_from_observability_snapshot, serialization-key coverage for the seven fields; admit-under-pressure / no-leak via the existingevicting_cold_prefix_restores_paged_block_budgetCloses #122.