#block-device #ublk #gpu-compression #zram #gpu

bin+lib trueno-ublk

Pure Rust ublk block device for compressed RAM storage (educational - use kernel zram for production)

3 unstable releases

0.3.1 Feb 15, 2026
0.3.0 Jan 8, 2026
0.2.0 Jan 6, 2026

#1025 in Compression


Used in aprender-orchestrate

MIT/Apache

1.5MB
31K SLoC

trueno-ublk - GPU-accelerated ZRAM replacement using ublk

This crate provides a ublk-based block device with SIMD and GPU-accelerated compression. It can be used as a drop-in replacement for Linux kernel ZRAM.

Features

  • SIMD acceleration: AVX2, AVX-512, and NEON support via trueno-zram-core
  • GPU offload: CUDA-based batch compression for large workloads
  • Entropy routing: Automatic algorithm selection based on data entropy
  • Zero-page deduplication: Efficient handling of all-zero pages
  • zram-compatible stats: Statistics format compatible with kernel zram

Example

use trueno_ublk::BlockDevice;
use trueno_zram_core::{Algorithm, CompressorBuilder, PAGE_SIZE};

// Create a compressor
let compressor = CompressorBuilder::new()
    .algorithm(Algorithm::Lz4)
    .build()
    .unwrap();

// Create a 1GB block device
let mut device = BlockDevice::new(1 << 30, compressor);

// Write data
let data = vec![0xAB; PAGE_SIZE];
device.write(0, &data).unwrap();

// Read back
let mut buf = vec![0u8; PAGE_SIZE];
device.read(0, &mut buf).unwrap();
assert_eq!(data, buf);

// Check stats
let stats = device.stats();
println!("Compression ratio: {:.2}x", stats.compression_ratio());

Dependencies

~73–98MB
~1.5M SLoC