DAX#
一个 L2 适配器,映射设备 DAX 路径,例如 /dev/daxX.X 和 /dev/daxY.Y,并在固定大小的槽中存储 KV Cache 对象。该适配器旨在用于字节可寻址内存设备,例如持久内存或 CXL 内存。
在此版本中,MP dax 适配器是易失性的。它将键索引保存在服务器内存中,并在重启时重建一个空索引。旧字节可能仍保留在 DAX 设备上,但在 LMCache 服务器重启后无法访问。
旧版单设备形式的必填字段:
device_path: 可映射的 DAX 设备或测试文件的路径。max_dax_size_gb: 从device_path映射的 GiB 数量。offset_gb(optional, default0): GiB offset where the mapping starts, so several servers, or L1 and L2 in one server, can share one CXL device on disjoint ranges. The range must fit within the device and be a multiple of the device alignment.slot_bytes: 固定槽大小(以字节为单位)。该值必须足够大,能够容纳一个完整的 LMCache 块,因为 MP 内存描述符不公开非 MP 模式下完整块的大小。
多设备形式的必填字段:
devices: List of objects withdevice_path,max_dax_size_gb, and optionaloffset_gb. The same device may appear more than once with disjoint ranges. The list may be empty only whenhotplug_enabledistrue.slot_bytes: 适配器门面中所有 DAX 设备共用的固定槽大小(以字节为单位)。
可选字段:
hotplug_enabled(bool, defaultfalse): Enables runtime/reconfigure/dax/l2/status,/reconfigure/dax/l2/add,/reconfigure/dax/l2/remove, and/reconfigure/dax/l2/resize.num_store_workers(int, default1): 存储工作线程数量。num_lookup_workers(int, default1): 查找工作线程数量。num_load_workers(int, defaultmin(4, os.cpu_count())): 加载工作线程数量。persist_enabled(bool): 通用 L2 配置解析会接受该字段,但对dax无效,因为重启恢复功能尚未实现。
配置示例:
# Backward-compatible single-device form.
--l2-adapter '{
"type": "dax",
"device_path": "/dev/dax1.0",
"max_dax_size_gb": 100,
"slot_bytes": 268435456,
"num_store_workers": 1,
"num_lookup_workers": 1,
"num_load_workers": 4,
"eviction": {
"eviction_policy": "LRU",
"trigger_watermark": 0.9,
"eviction_ratio": 0.1
}
}'
# Multi-device hotplug-ready form.
--l2-adapter '{
"type": "dax",
"devices": [
{"device_path": "/dev/daxX.X", "max_dax_size_gb": 100},
{"device_path": "/dev/daxX.X", "max_dax_size_gb": 100, "offset_gb": 100}
],
"slot_bytes": 268435456,
"hotplug_enabled": true,
"num_store_workers": 1,
"num_lookup_workers": 1,
"num_load_workers": 4
}'
运行时管理使用 JSON 请求体,因为 DAX 路径包含斜杠。完整示例请参阅 Device-DAX 后端指南。这些路由使用 StorageManager 的通用 L2 适配器重新配置 API:HTTP 路径用于选择后端和操作,DAX 适配器负责解析操作负载,未来的适配器(如 P2P)也可复用同一接口。
curl http://127.0.0.1:9000/reconfigure/dax/l2/status
curl -X POST http://127.0.0.1:9000/reconfigure/dax/l2/add \
-H 'Content-Type: application/json' \
-d '{"device_path": "/dev/daxX.X", "size": "100GiB", "offset": "200GiB"}'
Pass the same device_path and offset to remove and resize.
A range overlapping one this server already maps, in L1 or L2, returns 409.
当前限制:
运行时热插拔仅更改 LMCache 映射和元数据。它不会创建、销毁或重新配置内核 CXL 或 DAX 设备。
每个 TP 的分区和设备重启元数据尚未实现。
仅支持单缓冲区对象。多张量对象被拒绝。
容量以槽为单位计算,而非以负载字节计算。L2 逐出和使用量指标均基于已占用的槽数。
查找操作会持有 DAX 侧的外部锁。
submit_unlock在加载/检索完成后释放这些锁,使对应条目重新可被逐出。以
mode="evict"执行移除操作会破坏 DAX 层中的数据。以mode="migrate"执行移除操作则要求另一个活跃 DAX 设备具有足够的剩余容量。