mirror of
https://github.com/lightseekorg/tokenspeed.git
synced 2026-12-04 10:26:50 +08:00
Cache startup logs show capacity and packing without exposing field placement or unused bytes. Add an ASCII layout matrix after capacity agreement and PP narrowing, with cache group names as columns and resident planes as rows. The report includes physical packing and usable block counts, field offsets, shapes, and dtypes, stride padding, unused-plane holes, and per-parent payload utilization. Each column describes an alternative binding of the same parent. Serving builds log at INFO; memory probes log at DEBUG. The design documentation explains byte accounting, null-parent reservation, and PP and offload interpretation. Validation: - 44 CPU planner and visualization tests passed: `python -m pytest --noconftest -q test/runtime/test_cache_layout_visualization.py test/runtime/test_cache_memory_plan.py`. - Coverage includes shared-stride alignment gaps, trailing padding, unused planes, PP field and plane filtering, null-parent accounting, and large capacities. - `pre-commit run --all-files` passed. - GPU serving was not exercised. ## Example startup logs These examples use the cache field declarations with the same `pack()` and `format_cache_layout()` code as the startup report. Capacity is illustrative: **one usable parent plus one reserved null parent**, with `pp_rank=0`. Actual serving capacity follows memory budgeting and scheduler demand. Logger timestamps and rank prefixes are omitted. ### DeepSeek V4.1 Flash with DSpark Configuration: native `v41` cache format and **three DSpark stages**. The single `flatkv` plane is **3,225,600 B per parent**. The groups reuse that plane with different packing, so their columns describe alternative parent bindings and must not be added together. <details> <summary>Full V4.1 Flash + DSpark layout log</summary> ```text CacheRecipe DeepseekV41Recipe (deepseek_v41): build=serving, pp_rank=0 prefix_granularity=256 tokens, usable_parents=1, reserved_null_parents=1 logical_parent=3,225,600 B, resident_parent=3,225,600 B, layout_arena=6,451,200 B (0.006 GiB) Groups are alternative bindings of the same parent; do not sum columns. Packing and block counts are rank-local physical counts. Ranges [start, end) are bytes within one child stride, repeated packing times. Padding is unused space in an occupied plane; a hole is an unused plane. +--------------------+-----------------------------------+---------------------------------+-----------------------------------+------------------------------------------+ | plane | v41.compressor_tail_r2 | v41.global_r1 | v41.global_r2 | v41.swa | | | packing=126 | packing=140 | packing=45 | packing=2 | | | usable_blocks=126 | usable_blocks=140 | usable_blocks=45 | usable_blocks=2 | +--------------------+-----------------------------------+---------------------------------+-----------------------------------+------------------------------------------+ | flatkv | stride=25,600 B | stride=23,040 B | stride=71,680 B | stride=1,612,800 B | | parent=3,225,600 B | layer.14.compressor_tail | layer.20.global_kv | layer.14.global_kv | layer.0.swa | | arena_offset=0 B | [0, 8,192): 8,192 B | [0, 18,432): 18,432 B | [0, 18,432): 18,432 B | [0, 33,792): 33,792 B | | | float32 (2, 2, 512) | uint8 (64, 288) | uint8 (64, 288) | uint8 (64, 528) | | | layer.2.compressor_tail | layer.20.index_k | layer.14.index_k | layer.1.swa | | | [8,192, 16,384): 8,192 B | [18,432, 22,784): 4,352 B | [18,432, 22,784): 4,352 B | [33,792, 67,584): 33,792 B | | | float32 (2, 2, 512) | uint8 (64, 68) | uint8 (64, 68) | uint8 (64, 528) | | | layer.8.compressor_tail | padding [22,784, 23,040): 256 B | layer.2.global_kv | layer.10.swa | | | [16,384, 24,576): 8,192 B | payload=3,189,760 B/parent | [22,784, 41,216): 18,432 B | [67,584, 101,376): 33,792 B | | | float32 (2, 2, 512) | padding=35,840 B/parent | uint8 (64, 288) | uint8 (64, 528) | | | padding [24,576, 25,600): 1,024 B | | layer.2.index_k | layer.11.swa | | | payload=3,096,576 B/parent | | [41,216, 45,568): 4,352 B | [101,376, 135,168): 33,792 B | | | padding=129,024 B/parent | | uint8 (64, 68) | uint8 (64, 528) | | | | | layer.8.global_kv | layer.12.swa | | | | | [45,568, 64,000): 18,432 B | [135,168, 168,960): 33,792 B | | | | | uint8 (64, 288) | uint8 (64, 528) | | | | | layer.8.index_k | layer.13.swa | | | | | [64,000, 68,352): 4,352 B | [168,960, 202,752): 33,792 B | | | | | uint8 (64, 68) | uint8 (64, 528) | | | | | padding [68,352, 71,680): 3,328 B | layer.14.swa | | | | | payload=3,075,840 B/parent | [202,752, 236,544): 33,792 B | | | | | padding=149,760 B/parent | uint8 (64, 528) | | | | | | layer.15.swa | | | | | | [236,544, 270,336): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.16.swa | | | | | | [270,336, 304,128): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.17.swa | | | | | | [304,128, 337,920): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.18.swa | | | | | | [337,920, 371,712): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.19.swa | | | | | | [371,712, 405,504): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.2.swa | | | | | | [405,504, 439,296): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.20.swa | | | | | | [439,296, 473,088): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.21.swa | | | | | | [473,088, 506,880): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.22.swa | | | | | | [506,880, 540,672): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.23.swa | | | | | | [540,672, 574,464): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.24.swa | | | | | | [574,464, 608,256): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.25.swa | | | | | | [608,256, 642,048): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.26.swa | | | | | | [642,048, 675,840): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.27.swa | | | | | | [675,840, 709,632): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.28.swa | | | | | | [709,632, 743,424): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.29.swa | | | | | | [743,424, 777,216): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.3.swa | | | | | | [777,216, 811,008): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.30.swa | | | | | | [811,008, 844,800): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.31.swa | | | | | | [844,800, 878,592): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.32.swa | | | | | | [878,592, 912,384): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.33.swa | | | | | | [912,384, 946,176): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.34.swa | | | | | | [946,176, 979,968): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.35.swa | | | | | | [979,968, 1,013,760): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.36.swa | | | | | | [1,013,760, 1,047,552): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.37.swa | | | | | | [1,047,552, 1,081,344): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.38.swa | | | | | | [1,081,344, 1,115,136): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.39.dspark_kv0 | | | | | | [1,115,136, 1,180,672): 65,536 B | | | | | | bfloat16 (64, 512) | | | | | | layer.39.dspark_kv1 | | | | | | [1,180,672, 1,246,208): 65,536 B | | | | | | bfloat16 (64, 512) | | | | | | layer.39.dspark_kv2 | | | | | | [1,246,208, 1,311,744): 65,536 B | | | | | | bfloat16 (64, 512) | | | | | | layer.39.swa | | | | | | [1,311,744, 1,345,536): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.4.swa | | | | | | [1,345,536, 1,379,328): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.5.swa | | | | | | [1,379,328, 1,413,120): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.6.swa | | | | | | [1,413,120, 1,446,912): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.7.swa | | | | | | [1,446,912, 1,480,704): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.8.swa | | | | | | [1,480,704, 1,514,496): 33,792 B | | | | | | uint8 (64, 528) | | | | | | layer.9.swa | | | | | | [1,514,496, 1,548,288): 33,792 B | | | | | | uint8 (64, 528) | | | | | | padding [1,548,288, 1,612,800): 64,512 B | | | | | | payload=3,096,576 B/parent | | | | | | padding=129,024 B/parent | +--------------------+-----------------------------------+---------------------------------+-----------------------------------+------------------------------------------+ | TOTAL / parent | payload=3,096,576 B | payload=3,189,760 B | payload=3,075,840 B | payload=3,096,576 B | | 3,225,600 B | padding=129,024 B | padding=35,840 B | padding=149,760 B | padding=129,024 B | | | hole=0 B | hole=0 B | hole=0 B | hole=0 B | | | unused=129,024 B | unused=35,840 B | unused=149,760 B | unused=129,024 B | | | utilization=96.00% | utilization=98.89% | utilization=95.36% | utilization=96.00% | +--------------------+-----------------------------------+---------------------------------+-----------------------------------+------------------------------------------+ ``` </details> ### Kimi K3 with DSpark Configuration: **TP8, five MLA draft layers, FP8 KV for both target and draft, and FP32 KDA recurrent state**. The parent has 24 target MLA planes and five draft planes, totaling **25,657,344 B**. The reported `uint8` dtype is the FP8 KV storage view. Each KDA group has 23 layers and uses `slot.0` through `slot.22`. `slot.23` and the five draft planes (`slot.24` through `slot.28`) are unused by a KDA binding: **5,308,416 B of holes**, plus **1,625,088 B of stride padding**, giving **72.98% payload utilization**. The excerpt below preserves the original table formatting and includes `slot.0`, `slot.23`, `slot.24`, `slot.28`, and the totals. Other plane rows are omitted; totals cover all 29 planes. <details> <summary>K3 TP8 + DSpark layout log (selected planes and complete totals)</summary> ```text CacheRecipe KimiK3Recipe (kimi_k3): build=serving, pp_rank=0 prefix_granularity=128 tokens, usable_parents=1, reserved_null_parents=1 logical_parent=25,657,344 B, resident_parent=25,657,344 B, layout_arena=51,314,688 B (0.048 GiB) Groups are alternative bindings of the same parent; do not sum columns. Packing and block counts are rank-local physical counts. Ranges [start, end) are bytes within one child stride, repeated packing times. Padding is unused space in an occupied plane; a hole is an unused plane. +---------------------------+--------------------------+--------------------------------------+--------------------------------------+--------------------------------------+ | plane | full_attention | linear_attention_0 | linear_attention_1 | linear_attention_2 | | | packing=12 | packing=1 | packing=1 | packing=1 | | | usable_blocks=12 | usable_blocks=1 | usable_blocks=1 | usable_blocks=1 | +---------------------------+--------------------------+--------------------------------------+--------------------------------------+--------------------------------------+ | slot.0 | stride=73,728 B | stride=884,736 B | stride=884,736 B | stride=884,736 B | | parent=884,736 B | layer.3.latent_kv | layer.0.conv_state | layer.30.conv_state | layer.61.conv_state | | arena_offset=0 B | [0, 73,728): 73,728 B | [0, 27,648): 27,648 B | [0, 27,648): 27,648 B | [0, 27,648): 27,648 B | | | uint8 (128, 1, 576) | bfloat16 (4608, 3) | bfloat16 (4608, 3) | bfloat16 (4608, 3) | | | payload=884,736 B/parent | layer.0.recurrent_state | layer.30.recurrent_state | layer.61.recurrent_state | | | padding=0 B/parent | [27,648, 814,080): 786,432 B | [27,648, 814,080): 786,432 B | [27,648, 814,080): 786,432 B | | | | float32 (12, 128, 128) | float32 (12, 128, 128) | float32 (12, 128, 128) | | | | padding [814,080, 884,736): 70,656 B | padding [814,080, 884,736): 70,656 B | padding [814,080, 884,736): 70,656 B | | | | payload=814,080 B/parent | payload=814,080 B/parent | payload=814,080 B/parent | | | | padding=70,656 B/parent | padding=70,656 B/parent | padding=70,656 B/parent | +---------------------------+--------------------------+--------------------------------------+--------------------------------------+--------------------------------------+ | slot.23 | stride=73,728 B | hole=884,736 B/parent | hole=884,736 B/parent | hole=884,736 B/parent | | parent=884,736 B | layer.92.latent_kv | | | | | arena_offset=28,311,552 B | [0, 73,728): 73,728 B | | | | | | uint8 (128, 1, 576) | | | | | | payload=884,736 B/parent | | | | | | padding=0 B/parent | | | | +---------------------------+--------------------------+--------------------------------------+--------------------------------------+--------------------------------------+ | slot.24 | stride=73,728 B | hole=884,736 B/parent | hole=884,736 B/parent | hole=884,736 B/parent | | parent=884,736 B | layer.93.latent_kv | | | | | arena_offset=30,081,024 B | [0, 73,728): 73,728 B | | | | | | uint8 (128, 1, 576) | | | | | | payload=884,736 B/parent | | | | | | padding=0 B/parent | | | | +---------------------------+--------------------------+--------------------------------------+--------------------------------------+--------------------------------------+ | slot.28 | stride=73,728 B | hole=884,736 B/parent | hole=884,736 B/parent | hole=884,736 B/parent | | parent=884,736 B | layer.97.latent_kv | | | | | arena_offset=37,158,912 B | [0, 73,728): 73,728 B | | | | | | uint8 (128, 1, 576) | | | | | | payload=884,736 B/parent | | | | | | padding=0 B/parent | | | | +---------------------------+--------------------------+--------------------------------------+--------------------------------------+--------------------------------------+ | TOTAL / parent | payload=25,657,344 B | payload=18,723,840 B | payload=18,723,840 B | payload=18,723,840 B | | 25,657,344 B | padding=0 B | padding=1,625,088 B | padding=1,625,088 B | padding=1,625,088 B | | | hole=0 B | hole=5,308,416 B | hole=5,308,416 B | hole=5,308,416 B | | | unused=0 B | unused=6,933,504 B | unused=6,933,504 B | unused=6,933,504 B | | | utilization=100.00% | utilization=72.98% | utilization=72.98% | utilization=72.98% | +---------------------------+--------------------------+--------------------------------------+--------------------------------------+--------------------------------------+ ``` </details> Signed-off-by: FC-Li <robert_lexis@163.com>
250 lines
8.0 KiB
Python
250 lines
8.0 KiB
Python
# Copyright (c) 2026 LightSeek Foundation
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be included in
|
|
# all copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
# SOFTWARE.
|
|
|
|
"""Startup layout reports over real packed plans, without device allocations."""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
from ci_system.ci_register import register_cuda_ci
|
|
|
|
from tokenspeed.runtime.layers.attention.kv_cache.recipes.plan import (
|
|
CacheFieldSpec,
|
|
pack,
|
|
)
|
|
from tokenspeed.runtime.layers.attention.kv_cache.recipes.spec import CacheGroupSpec
|
|
from tokenspeed.runtime.layers.attention.kv_cache.recipes.visualization import (
|
|
format_cache_layout,
|
|
)
|
|
|
|
register_cuda_ci(
|
|
est_time=1,
|
|
suite="runtime-1gpu",
|
|
nightly=False,
|
|
disabled=None,
|
|
disabled_on_runners=None,
|
|
disabled_on_runners_reason=None,
|
|
)
|
|
|
|
|
|
def _layout():
|
|
history = CacheGroupSpec(
|
|
"full_attention",
|
|
"full_history",
|
|
rows_per_page=16,
|
|
entry_stride_tokens=1,
|
|
replayable=False,
|
|
)
|
|
state = CacheGroupSpec("linear_attention_0", "state", replayable=False)
|
|
return pack(
|
|
(
|
|
(
|
|
history,
|
|
(
|
|
CacheFieldSpec("layer.0.key", "unit.0", (16,), "uint8"),
|
|
CacheFieldSpec(
|
|
"layer.0.value",
|
|
"unit.1",
|
|
(31,),
|
|
"uint8",
|
|
exact_page_stride=False,
|
|
),
|
|
),
|
|
),
|
|
(
|
|
state,
|
|
(
|
|
CacheFieldSpec(
|
|
"layer.1.a", "unit.0", (3,), "uint8", exact_page_stride=False
|
|
),
|
|
CacheFieldSpec(
|
|
"layer.1.b", "unit.0", (1,), "float32", exact_page_stride=False
|
|
),
|
|
),
|
|
),
|
|
),
|
|
prefix_granularity=16,
|
|
cache_blocks_per_lcm_block={"full_attention": 1, "linear_attention_0": 2},
|
|
alignment=16,
|
|
max_padding_fraction=float("inf"),
|
|
)
|
|
|
|
|
|
def _table_cells(report):
|
|
"""Read the displayed rows and columns, ignoring alignment whitespace."""
|
|
rows = []
|
|
row = []
|
|
for line in report.splitlines():
|
|
if line.startswith("|"):
|
|
row.append([cell.strip() for cell in line.split("|")[1:-1]])
|
|
elif line.startswith("+") and row:
|
|
rows.append(list(zip(*row, strict=True)))
|
|
row = []
|
|
return {row[0][0]: [list(filter(None, cell)) for cell in row] for row in rows}
|
|
|
|
|
|
def test_group_columns_and_plane_rows_show_field_offsets_and_packing():
|
|
plan = _layout().bind(3)
|
|
report = format_cache_layout(plan)
|
|
rows = _table_cells(report)
|
|
|
|
assert list(rows) == ["plane", "unit.0", "unit.1", "TOTAL / parent"]
|
|
assert rows["plane"] == [
|
|
["plane"],
|
|
["full_attention", "packing=1", "usable_blocks=3"],
|
|
["linear_attention_0", "packing=2", "usable_blocks=6"],
|
|
]
|
|
assert rows["unit.0"][1] == [
|
|
"stride=16 B",
|
|
"layer.0.key",
|
|
"[0, 16): 16 B",
|
|
"uint8 (16,)",
|
|
"payload=16 B/parent",
|
|
"padding=0 B/parent",
|
|
]
|
|
assert rows["unit.0"][2] == [
|
|
"stride=8 B",
|
|
"layer.1.a",
|
|
"[0, 3): 3 B",
|
|
"uint8 (3,)",
|
|
"padding [3, 4): 1 B",
|
|
"layer.1.b",
|
|
"[4, 8): 4 B",
|
|
"float32 (1,)",
|
|
"payload=14 B/parent",
|
|
"padding=2 B/parent",
|
|
]
|
|
assert "padding [31, 32): 1 B" in rows["unit.1"][1]
|
|
assert rows["unit.1"][2] == ["hole=32 B/parent"]
|
|
# The plane arrays include one reserved parent, even though usable block
|
|
# counts exclude it. Field offsets above are relative to a child stride.
|
|
assert rows["unit.1"][0] == ["unit.1", "parent=32 B", "arena_offset=64 B"]
|
|
assert "usable_parents=3, reserved_null_parents=1" in report
|
|
assert "logical_parent=48 B, resident_parent=48 B, layout_arena=192 B" in report
|
|
|
|
|
|
def test_parent_totals_count_shared_stride_padding_once():
|
|
rows = _table_cells(format_cache_layout(_layout().bind(3)))
|
|
|
|
assert rows["TOTAL / parent"] == [
|
|
["TOTAL / parent", "48 B"],
|
|
[
|
|
"payload=47 B",
|
|
"padding=1 B",
|
|
"hole=0 B",
|
|
"unused=1 B",
|
|
"utilization=97.92%",
|
|
],
|
|
[
|
|
"payload=14 B",
|
|
"padding=2 B",
|
|
"hole=32 B",
|
|
"unused=34 B",
|
|
"utilization=29.17%",
|
|
],
|
|
]
|
|
|
|
|
|
def test_pp_reports_only_resident_planes_and_preserves_global_packing():
|
|
plan = _layout().bind(3).narrow_to_layers(1, 2)
|
|
report = format_cache_layout(plan)
|
|
rows = _table_cells(report)
|
|
|
|
assert list(rows) == ["plane", "unit.0", "TOTAL / parent"]
|
|
assert rows["unit.0"][1] == ["hole=16 B/parent"]
|
|
assert "packing=2" in rows["plane"][2]
|
|
assert rows["TOTAL / parent"][2] == [
|
|
"payload=14 B",
|
|
"padding=2 B",
|
|
"hole=0 B",
|
|
"unused=2 B",
|
|
"utilization=87.50%",
|
|
]
|
|
assert "logical_parent=48 B, resident_parent=16 B, layout_arena=64 B" in report
|
|
assert "layer.0." not in report
|
|
|
|
|
|
def test_pp_retains_leading_and_trailing_padding_in_a_shared_stride():
|
|
state = CacheGroupSpec("state", "state", replayable=False)
|
|
layout = pack(
|
|
(
|
|
(
|
|
state,
|
|
(
|
|
CacheFieldSpec(
|
|
"layer.0.a", "shared", (3,), "uint8", exact_page_stride=False
|
|
),
|
|
CacheFieldSpec(
|
|
"layer.1.b", "shared", (1,), "float32", exact_page_stride=False
|
|
),
|
|
),
|
|
),
|
|
),
|
|
prefix_granularity=16,
|
|
cache_blocks_per_lcm_block={"state": 1},
|
|
alignment=16,
|
|
max_padding_fraction=float("inf"),
|
|
)
|
|
plan = layout.bind(3).narrow_to_layers(1, 2)
|
|
rows = _table_cells(format_cache_layout(plan))
|
|
|
|
assert rows["shared"][1] == [
|
|
"stride=16 B",
|
|
"padding [0, 4): 4 B",
|
|
"layer.1.b",
|
|
"[4, 8): 4 B",
|
|
"float32 (1,)",
|
|
"padding [8, 16): 8 B",
|
|
"payload=4 B/parent",
|
|
"padding=12 B/parent",
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("parents", [1, 1_000_000_000])
|
|
def test_report_does_not_expand_parent_or_packing_counts(parents):
|
|
layout = _layout()
|
|
report = format_cache_layout(layout.bind(parents))
|
|
rows = _table_cells(report)
|
|
|
|
assert f"usable_blocks={parents * 2:,}" in rows["plane"][2]
|
|
assert f"layout_arena={(parents + 1) * 48:,} B" in report
|
|
assert len(report.splitlines()) == len(
|
|
format_cache_layout(layout.bind(1)).splitlines()
|
|
)
|
|
|
|
|
|
def test_empty_resident_window_reports_zero_bytes():
|
|
report = format_cache_layout(_layout().bind(3).narrow_to_layers(2, 3))
|
|
rows = _table_cells(report)
|
|
|
|
assert "logical_parent=48 B, resident_parent=0 B, layout_arena=0 B" in report
|
|
assert list(rows) == ["plane", "TOTAL / parent"]
|
|
for cell in rows["TOTAL / parent"][1:]:
|
|
assert cell == [
|
|
"payload=0 B",
|
|
"padding=0 B",
|
|
"hole=0 B",
|
|
"unused=0 B",
|
|
"utilization=0.00%",
|
|
]
|