Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

LMCache Rust Raw Block I/O

This crate provides the low-level raw device I/O layer for LMCache via Rust + PyO3. It is used by both:

  • the legacy non-MP RustRawBlockBackend
  • the MP raw_block L2 adapter (RawBlockL2Adapter) via RawBlockCore

The Rust crate intentionally stays narrow: it owns the raw device handle and exposes blocking pwrite_from_buffer / pread_into primitives. Slotting, checkpointing, recovery, and MP task orchestration all live in Python.

I/O Engines

RawBlockDevice accepts io_engine:

  • posix (default): synchronous Linux pread / pwrite.
  • io_uring: direct Rust io_uring syscall path using the existing worker, batch, and wait_iouring machinery.

use_iouring=True remains accepted for backward compatibility. If io_engine is explicitly set, it wins over the legacy flag.

io_uring_cmd (NVMe Passthrough)

When io_engine="io_uring", you can optionally enable use_uring_cmd=True to use NVMe passthrough via the io_uring command interface for direct device access.

io_uring_cmd notes:

  • Requires NVMe character device node (/dev/ngXnY) instead of the block device node (/dev/nvmeXnY) for direct NVMe passthrough command.
  • Requires io_engine="io_uring" to be set.
  • Supports max_data_transfer_size parameter to split large transfers into smaller chunks that fit within device limits.
  • Requires alignment to be a multiple of the NVMe namespace LBA size. An incompatible value is rejected when the device opens.
  • When use_uring_cmd=True, use_odirect is ignored for NVMe namespace character devices.
  • wait_iouring returns a success bitmap and a sparse (operation_index, error_message) list after the worker releases the request's global and per-batch in-flight accounting. Use wait_iouring_exceptions(batch_id) to get the same bitmap and the original exception objects. Both methods consume the batch. A payload UECC is an instance of lmcache_rust_raw_block_io.NvmeUnrecoveredReadError.

MP Mode Integration

In MP mode, the stack looks like this:

StoreController / PrefetchController
                |
                v
        RawBlockL2Adapter
                |
                v
           RawBlockCore
                |
                v
         lmcache_rust_raw_block_io
                |
                v
         raw device / file

This split lets LMCache reuse the same on-device metadata and recovery model in both non-MP and MP mode without duplicating the raw-block implementation. During restart recovery, the shared RawBlockCore validates POSIX per-slot headers with an internal pool of 8 reader threads. Both regular io_uring and io_uring_cmd batch header reads up to iouring_queue_depth.

Zero-Copy Data Path

LMCache LocalCPUBackend (aligned pinned CPU tensor)
                 |
                 |  Python buffer / memoryview (no payload memcpy)
                 v
RustRawBlockBackend (PyO3 boundary)
                 |
                 |  direct pointer path when O_DIRECT constraints are met
                 |  fallback: bounce only for unaligned tail/block
                 v
RawBlockDevice::pwrite_from_buffer / pread_into
                 |
                 v
Block device or file

How To Compare Performance

To compare local_disk vs rust_raw_block on a real NVMe device:

  • Run local_disk on an ext4 mount of the device.
  • Unmount it.
  • Run rust_raw_block directly on the raw block device.

Use the multiprocess benchmark tooling under lmcache bench to compare the backends on the target host.

No fixed numbers are included here because results are host/device/workload dependent.

Limitations

  • Linux only (pread / pwrite, O_DIRECT semantics).
  • alignment and block_align must be powers of two, such as 4096.
  • O_DIRECT requires aligned offsets and I/O lengths. batched_write rejects requests whose offset or total_len is not a multiple of the configured alignment; misaligned write buffers are copied through an aligned bounce buffer.
  • write_uring and batched_write take a logical payload length alongside the physical transfer length (write_uring's total_len defaults to payload_len; batched_write's payload_lens defaults to total_lens). They read only within the source buffer bounds, never modify it, and always write the padding region as zeroes. A bounce buffer is used when the source is shorter than the transfer length or its padding tail is not already zero, so a caller buffer whose tail is zero keeps the fixed-buffer zero-copy path.

Build

cd rust/raw_block
pip install maturin
maturin develop --release

Minimal Usage

from lmcache_rust_raw_block_io import RawBlockDevice

dev = RawBlockDevice("/dev/nvme0n1", True, use_odirect=True, alignment=4096)
dev.pwrite_from_buffer(offset=0, data=b"hello", total_len=4096)

buf = bytearray(4096)
dev.pread_into(offset=0, out=buf, payload_len=5, total_len=4096)

io_uring:

dev = RawBlockDevice(
    "/dev/nvme0n1",
    True,
    use_odirect=True,
    alignment=4096,
    io_engine="io_uring",
    iouring_queue_depth=256,
)

io_uring with io_uring_cmd (NVMe passthrough):

dev = RawBlockDevice(
    "/dev/ng0n1",  # Note: NVMe character device node
    True,
    use_odirect=False,
    alignment=4096,
    io_engine="io_uring",
    use_uring_cmd=True,
    iouring_queue_depth=256,
    max_data_transfer_size=131072,  # Optional: split large transfers
)

FDP Notes

FDP status can be queried from Python when use_uring_cmd=True:

status = dev.fetch_fdp_status()  # [(placement_id, ruh_id), ...]

For writes, omitting placement_id leaves the NVMe directive unset (dtype=0, dspec=0). NVMe default writes use the RUH mapping associated with Placement Identifier 0, so LMCache rejects explicit placement_id=0 at the RawBlockCore layer. The low-level status query reads the controller-reported 16-bit NRUHSD count.

MP Adapter Example

To use the MP adapter from lmcache server, pass a raw_block L2 adapter config:

lmcache server --transport grpc --host 127.0.0.1 --port 5555 \
  --l1-size-gb 10 \
  --eviction-policy LRU \
  --l1-align-bytes 4096 \
  --l2-adapter '{
    "type": "raw_block",
    "device_path": "/dev/nvme0n1",
    "slot_bytes": 1048576,
    "block_align": 4096,
    "header_bytes": 4096,
    "meta_total_bytes": 268435456,
    "use_odirect": true,
    "io_engine": "io_uring",
    "num_store_workers": 2,
    "num_lookup_workers": 1,
    "num_load_workers": 4
  }'

Connect the MP client to grpc://127.0.0.1:5555. The scheme-less endpoint 127.0.0.1:5555 also selects gRPC on the current default transport.

Notes:

  • device_path should point to an unmounted raw block device or a dedicated file used only by LMCache.
  • For use_uring_cmd=true, device_path must use the NVMe character device node (e.g., /dev/ng0n1) instead of the block device node.
  • block_align must be a power of two. slot_bytes, header_bytes, and meta_total_bytes must be multiples of block_align.
  • With use_odirect=true, LMCache MP L1 alignment must be at least block_align.
  • Restart recovery uses the metadata checkpoint region on the same device.
  • Raw-block slot reclamation is driven by the shared/global L2 eviction controller or explicit delete() calls.
  • raw_block remains the adapter type for all supported engines.

Metadata

Release files for lmcache-rust-raw-block-io 0.5.9rc2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for lmcache-rust-raw-block-io 0.5.9rc2
File Actions
lmcache_rust_raw_block_io-0.5.9rc2-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details for lmcache_rust_raw_block_io-0.5.9rc2-cp313-cp313-manylinux_2_28_x86_64.whl
lmcache_rust_raw_block_io-0.5.9rc2-cp313-cp313-manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ ARM64 Details for lmcache_rust_raw_block_io-0.5.9rc2-cp313-cp313-manylinux_2_28_aarch64.whl
lmcache_rust_raw_block_io-0.5.9rc2-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for lmcache_rust_raw_block_io-0.5.9rc2-cp312-cp312-manylinux_2_28_x86_64.whl
lmcache_rust_raw_block_io-0.5.9rc2-cp312-cp312-manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ ARM64 Details for lmcache_rust_raw_block_io-0.5.9rc2-cp312-cp312-manylinux_2_28_aarch64.whl
lmcache_rust_raw_block_io-0.5.9rc2-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details for lmcache_rust_raw_block_io-0.5.9rc2-cp311-cp311-manylinux_2_28_x86_64.whl
lmcache_rust_raw_block_io-0.5.9rc2-cp311-cp311-manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ ARM64 Details for lmcache_rust_raw_block_io-0.5.9rc2-cp311-cp311-manylinux_2_28_aarch64.whl
lmcache_rust_raw_block_io-0.5.9rc2-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details for lmcache_rust_raw_block_io-0.5.9rc2-cp310-cp310-manylinux_2_28_x86_64.whl
lmcache_rust_raw_block_io-0.5.9rc2-cp310-cp310-manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ ARM64 Details for lmcache_rust_raw_block_io-0.5.9rc2-cp310-cp310-manylinux_2_28_aarch64.whl

Total release size: 3.1 MB

Release files / lmcache_rust_raw_block_io-0.5.9rc2-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL lmcache_rust_raw_block_io-0.5.9rc2-cp313-cp313-manylinux_2_28_x86_64.whl
Size 392.4 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
71e4ecde0211814f4ffd66e1a7263c6b32061357182ec94f566b02ad9c9a298b
BLAKE2b-256 checksum
How to use checksums
ef68db1c39cc1cb94fd1dce8c36906c0cdff712b3049197a2c453c599efd5f90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / lmcache_rust_raw_block_io-0.5.9rc2-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL lmcache_rust_raw_block_io-0.5.9rc2-cp313-cp313-manylinux_2_28_aarch64.whl
Size 391.7 kB
Tags CPython 3.13 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
cbd39a288d969e9397ec11c80a94674a753ab07a69a1c86e9ccef2839e0547ce
BLAKE2b-256 checksum
How to use checksums
6645800ed03a2ec4a29b09bbcc6d407424a5121307ade9138e54b8a2d55f8c2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / lmcache_rust_raw_block_io-0.5.9rc2-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL lmcache_rust_raw_block_io-0.5.9rc2-cp312-cp312-manylinux_2_28_x86_64.whl
Size 393.0 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b66c08415957613885a540507aac0b7cb513d5075d2c460fdf8264d4355465a1
BLAKE2b-256 checksum
How to use checksums
bde80fef7d8f7225129343eb39c2366059f00323b8fd55ae3ae79aea0a755c5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / lmcache_rust_raw_block_io-0.5.9rc2-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL lmcache_rust_raw_block_io-0.5.9rc2-cp312-cp312-manylinux_2_28_aarch64.whl
Size 391.8 kB
Tags CPython 3.12 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
bea26144bd2bf7cb716dd8de0711cc93dce52a81c1fcf6b0262ccbbe6e2a9a0f
BLAKE2b-256 checksum
How to use checksums
93209bd1e8bea60e5ca59235530c8b363bf43e8b4784f81476df3da66d5be233
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / lmcache_rust_raw_block_io-0.5.9rc2-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL lmcache_rust_raw_block_io-0.5.9rc2-cp311-cp311-manylinux_2_28_x86_64.whl
Size 393.5 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
60c1db98c561f2e556b4100d2ad665474027d8039fde39e84eb74eb8072a120f
BLAKE2b-256 checksum
How to use checksums
931cce1cf31af0189f553cd3e2cb35c72a82d3bff1171a26466c161463cc2304
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / lmcache_rust_raw_block_io-0.5.9rc2-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL lmcache_rust_raw_block_io-0.5.9rc2-cp311-cp311-manylinux_2_28_aarch64.whl
Size 392.8 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
4566b58b7772b62779a39893c0e0aba9943e350b911ed7fff38786478cee46d0
BLAKE2b-256 checksum
How to use checksums
e78d4918e09ea615d0a4ab18ba63bcddf6f36fbf98311c51633862b4db6436da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / lmcache_rust_raw_block_io-0.5.9rc2-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL lmcache_rust_raw_block_io-0.5.9rc2-cp310-cp310-manylinux_2_28_x86_64.whl
Size 393.4 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0a05afbb338ed8344baa1fccf22a8511efc9abf037a0e5380a032356a533026d
BLAKE2b-256 checksum
How to use checksums
d96bfb4ad8934b7c9e483c31c9f375df0980139ee2fefac649b350ecffedd6ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / lmcache_rust_raw_block_io-0.5.9rc2-cp310-cp310-manylinux_2_28_aarch64.whl

Download URL lmcache_rust_raw_block_io-0.5.9rc2-cp310-cp310-manylinux_2_28_aarch64.whl
Size 391.6 kB
Tags CPython 3.10 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
294ee165aa90b1f5b61cff5a49572b173d3d3990f30b23452c3212699f4cad74
BLAKE2b-256 checksum
How to use checksums
4601411ef1466e4c3c95021ccb8516d0cf2713f155134ecfe2369cf93c3e8d68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for lmcache-rust-raw-block-io 0.5.9rc2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for lmcache_rust_raw_block_io-0.5.9rc2-cp313-cp313-manylinux_2_28_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page