Skip to main content

Crate trueno_ublk

Crate trueno_ublk 

Source
Expand description

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());

Re-exports§

pub use backend::BackendType;
pub use backend::EntropyThresholds;
pub use backend::StorageBackend;
pub use backend::TieredStorageManager;
pub use device::BlockDevice;
pub use device::BlockDeviceStats;
pub use device::DeviceConfig;
pub use device::DeviceStats;
pub use device::UblkDevice;
pub use ublk::DaemonError;
pub use ublk::UblkCtrl;
pub use ublk::UblkDaemon;
pub use duende_lifecycle::create_daemon;
pub use duende_lifecycle::setup_duende_signals;
pub use duende_lifecycle::TruenoUblkDaemon;
pub use ublk::run_daemon;
pub use ublk::run_daemon_batched;
pub use ublk::BatchedDaemonConfig;
pub use daemon::spawn_flush_thread;
pub use daemon::BatchConfig;
pub use daemon::BatchedPageStore;
pub use daemon::BatchedPageStoreStats;
pub use perf::HiPerfContext;
pub use perf::PerfConfig;
pub use perf::PollResult;
pub use perf::PollingConfig;
pub use perf::TenXConfig;
pub use perf::TenXContext;
pub use visualize::TruenoCollector;

Modules§

backend
Storage Backend Module - Kernel-Cooperative Architecture (KERN-001)
cleanup
Cleanup module - Orphan device detection and graceful shutdown
daemon
Daemon module - ublk I/O processing
device
Device module - ublk device management
duende_lifecycle
Duende daemon lifecycle integration (DT-008)
perf
PERF-001: Performance Optimization Module
stats
Statistics module - real-time stats collection and aggregation
ublk
Zero-dependency ublk implementation
visualize
Renacer visualization integration (VIZ-001/002/003/004).

Enums§

MlockStatus
Result of a memory locking operation.

Functions§

is_memory_locked
Check if process memory is currently locked.
lock_daemon_memory
Lock all current and future memory allocations.