WSL 2 File System Performance Improvements via Per-Device SWIOTLB Pools

WSL 2 is improving cross-OS file system access by eliminating a major contention point in the DMA layer. A change merged in May 2026 (PR #40654) provides each virtio device with its own dedicated DMA pool, which prevents I/O bottlenecks when multiple devices, such as network adapters and multiple drive mounts, compete for the same memory buffers.

Per-Device SWIOTLB Pools for Virtiofs

Virtual machines on Hyper-V use bounce buffers—reserved memory regions below the 4 GB DMA boundary—to perform I/O. In the Linux kernel, these are known as SWIOTLB pools. Previously, all virtio devices in a WSL 2 session shared a single global pool. This meant that a virtiofs mount for /mnt/c, a mount for /mnt/d, and the virtio network adapter all queued into the same buffer, creating significant contention during heavy I/O workloads.

PR #40654, authored by Ben Hillis, resolves this by allocating a contiguous physical range below 4 GB at boot. The WSL service now reads the swiotlb_base and swiotlb_size from sysfs and injects a per-device swiotlb= option during device creation. This ensures that each virtio device has its own dedicated DMA pool, removing the shared queue bottleneck.

Technical Requirements

To benefit from this optimization, the following requirements must be met:

  • Kernel Version: Microsoft.WSL.Kernel 6.18.26.3-1 or newer.
  • WSL 2 DeviceHost: Version 1.2.29-0.
  • Memory: The WSL 2 session must have more than 1 GB of RAM, as the SWIOTLB pool requires at least 64 MB of headroom.

Optimizing Cross-OS Workflows

This update specifically targets file-heavy workflows that cross the Windows/Linux boundary, such as running cargo build, npm install, or mvn package in a project located on a Windows drive (e.g., /mnt/c/Users/you/code). By reducing DMA contention, the performance of virtiofs is further enhanced.

How to Enable the Optimization

Because virtiofs is still an opt-in feature, users must manually enable it to see these gains:

  1. Add virtiofs=true to the [wsl2] section of your .wslconfig file.
  2. Update the WSL kernel using the command: wsl.exe --update --pre-release.

Evolution of WSL File System Access

Cross-OS file access has evolved through three primary architectural shifts to address performance gaps:

  • WSL 1 (DrvFs): Used a custom filesystem driver in the Windows NT kernel. It was fast for file-heavy workloads because there was no VM boundary.
  • WSL 2 (Plan 9/9P): Introduced a full Linux kernel in a Hyper-V VM. Initial cross-OS access used a Plan 9 (9P) file server over a Hyper-V socket, which suffered from protocol overhead due to a 64 KB message size limit (msize=65536).
  • WSL 2 (virtiofs): Introduced as an experimental opt-in to use the VirtIO transport for shared-memory file access, significantly reducing serialization overhead compared to 9P.

Community Perspectives and Trade-offs

While the technical improvements are the DMA layer fix, community discussion highlights a persistent tension between the native Linux experience and the WSL 2 virtualization layer.

"WSL singlehandedly stemmed much of tide of developers moving away from Windows, but WSL native filesystem performance gave devs that magical experience when they boot into Linux the first time and see that the filesystem doesn't have to be ass."

Some users noted that while virtiofs improves the gap, some still prefer native Linux or macOS for local development to avoid the overhead of a VM boundary entirely. Others mentioned that the architectural shift from WSL 1's syscall translation layer to WSL 2's VM-based approach was a trade-off that initially degraded file system performance for the reason of gaining better syscall compatibility.

Other reported benefits include faster WSL launches and improved performance for VirtioProxy networking, which also utilizes the same DMA infrastructure.

Sources