microsoft / microsoft/WSL

Kernel Mitigations in WSL2 leading to 30-50% worse wall time, 80% worse syscall time

Open
#14,526 6 comments 0 reactions 0 assignees View on GitHub
kconfig
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

### Windows Version

Microsoft Windows [Version 10.0.26220.8079]

### WSL Version

WSL version: 2.6.3.0

### Are you using WSL 1 or WSL 2?

- [x] WSL 2
- [ ] WSL 1

### Kernel Version

6.6.87.2-1

### Distro Version

Debian 13.4

### Other Software
* go version `go1.26.1 linux/amd64`

## Summary
Kernel side-channel mitigations seem to affect WSL2 performance more heavily than a normal linux kernel. A normal kernel with `mitigations=on` will see 5-10% performance impact. With wsl2, mitigations cause 84% syscall impact, and 47% compile time (wall time) impact for a moderate golang compile.

### Repro Steps

Steps to Reproduce
1. Run `perf bench sched pipe -l 100000`
2. Run `go clean -cache && go build ./...`
3. Add `kernelCommandLine=quiet loglevel=0 audit=0 mitigations=off vsyscall=none` to %UserProfile%\.wslconfig.
4. `wsl --shutdown` & re-run the tests

### Expected Behavior

5-10% performance difference between `mitigations=on` and `mitigations=off`

### Actual Behavior

### Context Switch Latency (`perf bench sched pipe -l 100000`)
Metric | Mitigations OFF | Mitigations ON (Default) | Regression
-- | -- | -- | --
Latency (usecs/op) | 37.51 μs | 44.45 μs | +18.5%
Throughput (ops/sec) | 26,659 | 22,493 | -15.6%

### go build benchmark -- 84% worse system time, 47% worse wall time

Metric | Mitigations OFF | Mitigations ON (Default) | Regression
-- | -- | -- | --
System Time | 13.51s | 24.89s | +84.2%
Total (Wall) Time | 18.31s | 26.98s | +47.3%
CPU Efficiency (*higher=better*)| 522% | 395% | -127%

## Testing Mitigations

```
❯ grep Vuln /sys/devices/system/cpu/vulnerabilities/*
/sys/devices/system/cpu/vulnerabilities/spec_rstack_overflow:Vulnerable
/sys/devices/system/cpu/vulnerabilities/spec_store_bypass:Vulnerable
/sys/devices/system/cpu/vulnerabilities/spectre_v1:Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers
/sys/devices/system/cpu/vulnerabilities/spectre_v2:Vulnerable; IBPB: disabled; STIBP: disabled; PBRSB-eIBRS: Not affected; BHI: Not affected
```

Contributor guide

Open the contributing guide

Research direction

Start with the reported `perf bench sched pipe -l 100000` and `go clean -cache && go build ./...` benchmarks on WSL 2, comparing default mitigations with the `.wslconfig` kernel command line. Check the listed `/sys/devices/system/cpu/vulnerabilities/*` entries and the supplied kernel, Windows, WSL, and distro versions; done means identifying and explaining the mitigation-related regression or narrowing it to a reproducible WSL component.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, linux
Domain
operating-systems, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.