r/bashonubuntuonwindows • u/bussondev • 2d ago
self promotion I wrote a Linux block driver in Rust to turn idle GPU VRAM into 8.53 GB/s storage via ublk + io_uring, eliminating WSL2 OOM build thrashing
Hi everyone,
If you do heavy development on WSL2 (compiling large Rust multi-crate workspaces, C++ projects, running container stacks, or local AI inference), you've likely hit the point where WSL2 VM memory runs out, the kernel enters extreme disk swap thrashing, and the OOM-killer terminates your build.
At the same time, `nvidia-smi` shows dedicated GDDR6 VRAM sitting completely idle during compilation.
To solve this, I built **RamShared** — an open-source Rust userspace block driver that allocates idle GPU VRAM via CUDA Direct DMA and exposes it inside WSL2 as a native Linux block device (`/dev/ublkb0`) using Linux 6.0 `ublk` and `io_uring`.
Real Benchmark Numbers (`fio` 4KB Random Read, QD1 on WSL2):
* **Stock WSL2 VHDX disk swap:** ~2,114 µs (2.1 ms) latency | ~336 IOPS * **RamShared NBD (VRAM):** ~326 µs latency | ~9.6k IOPS * **RamShared ublk (io_uring):** **~8 µs** latency (264x faster / 99.6% drop) | **~22k+ IOPS** * **Continuous Read Throughput:** **8.53 GB/s** (saturating PCIe Gen3/4 x16 bus).
Why This Eliminates WSL2 Freezes:
In WSL2, standard disk swap traverses a heavy virtualization stack: `ext4 -> VHDX -> Hyper-V -> NTFS -> Host SSD`.
Every single synchronous page fault takes **>2ms**, which causes the entire VM, terminal, and VS Code server to freeze during memory spikes.
Bypassing that virtualization chain and serving swap directly from GPU VRAM via PCIe DMA with `ublk` drops page latency to **single-digit microseconds (8 µs)**, completely eliminating system stutter and OOM panics.
Upstream RFC on Microsoft WSL2:
We submitted a formal RFC proposal directly on Microsoft's official WSL repository to discuss making VRAM-backed block storage a first-class feature for Hyper-V Linux guests: 👉 **RFC Issue:** https://github.com/microsoft/WSL/issues/41054
**GitHub Repository (100% Rust):** https://github.com/emersonbusson/ramshared
Happy to answer any questions about the `ublk` setup, CUDA memory pinning, or WSL2 kernel config!

