get_tensor_mmap

Function get_tensor_mmap 

Source
pub async fn get_tensor_mmap(
    __arg0: Path<String>,
    __arg1: Query<TensorQuery>,
    headers: HeaderMap,
    mmap_cache: Arc<MmapCache>,
    tensor_storage_path: PathBuf,
) -> Result<Response, TensorError>
Expand description

Get tensor using memory-mapped I/O (zero-copy from disk)

GET /v1/tensor/{cid}/mmap

Retrieves tensor data using memory-mapped I/O for maximum performance. This endpoint is optimized for serving large tensors directly from disk without loading them into memory.

§Performance

  • Zero-copy: Data is served directly from disk via OS page cache
  • Lazy loading: Only requested pages are loaded into memory
  • OS optimizations: Leverages sendfile and similar system calls

§Limitations

  • Only works for tensors stored on local filesystem
  • Requires tensor file path to be available
  • Not suitable for tensors stored in distributed storage