Skip to content

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

Open

Description

Windows Version

Microsoft Windows [Version 10.0.26220.8079]

WSL Version

WSL version: 3.0.5 2.6.3.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

6.18.58.1-1 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

Activity

  1. github-actions commented on Mar 25, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to wsl-gh-logs@microsoft.com with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. tonymet commented on Mar 25, 2026

    @tonymet
    Author
  3. github-actions commented on Mar 25, 2026

    @github-actions
    Contributor
    Diagnostic information
    .wslconfig found
    	Custom kernel command line found: 'quiet loglevel=0 audit=0 mitigations=off vsyscall=none'
    Detected appx version: 2.6.3.0
    Found evidence of linux crash: !usr!bin!zsh (dump: C:\Users\tonymet\AppData\Local\temp\wsl-crashes\wsl-crash-1774454831-20871-_usr_bin_zsh-11.dmp)
    
  4. tonymet commented on Mar 25, 2026

    @tonymet
    Author

    control test of other kernel options .

    Result : mitigations=off is 11% faster

    A: mitigations=on kernelCommandLine=quiet loglevel=0 audit=0 mitigations=ON vsyscall=none

     perf bench sched pipe -l 100000
         Total time: 4.382 [sec]
    
          43.828820 usecs/op
              22816 ops/sec
    

    B: mitigations=off kernelCommandLine=quiet loglevel=0 audit=0 mitigations=off vsyscall=none

    
    ❯ perf bench sched pipe -l 100000
         Total time: 3.928 [sec]
    
          39.285230 usecs/op
              25454 ops/sec
    
  5. added
    kconfig
    on Mar 25, 2026
  6. thisismypassport commented on Jun 25, 2026

    @thisismypassport

    I think it's useful to know that "perf bench sched pipe -l 100000" speeds up by a factor of 20 if you add "chrt -i 0" before it (which enables idle scheduling) on WSL2.

    perf bench sched pipe -l 100000
    # Running 'sched/pipe' benchmark:
    # Executed 100000 pipe operations between two processes
    
         Total time: 5.549 [sec]
    
          55.499880 usecs/op
              18018 ops/sec
    
    chrt -i 0 perf bench sched pipe -l 100000
    # Running 'sched/pipe' benchmark:
    # Executed 100000 pipe operations between two processes
    
         Total time: 0.214 [sec]
    
           2.143640 usecs/op
             466496 ops/sec
    

    It has also improved some non-benchmark applications by a factor of 2 to 3 for me.

  7. tonymet commented on Jun 30, 2026

    @tonymet
    Author

    I think it's useful to know that "perf bench sched pipe -l 100000" speeds up by a factor of 20 if you add "chrt -i 0" before it (which enables idle scheduling) on WSL2.

    great find. do you think this is a configuration issue with the WSL kernel build? i'm hoping they can correct both performance issues. My builds are way faster now with these minor config changes.

  8. tonymet commented on Oct 6, 2026

    @tonymet
    Author

    new testing on WSL v3.0.2 -- mitigations=off is a 85% pipe operations improvement

    Findings

    1. 3.x series is 5x faster than 2.x series
    2. within 3.x series, mitigations=off is 85% faster than mitigations = on

    mitigations = off = 85% improvement

    .wslconfig:
    kernelCommandLine=quiet loglevel=0 audit=0 mitigations=off vsyscall=none

    # Running 'sched/pipe' benchmark:
    # Executed 100000 pipe operations between two processes
    
         Total time: 0.460 [sec]
    
           4.601930 usecs/op
             217300 ops/sec
    
    

    mitigations=ON

    # Running 'sched/pipe' benchmark:
    # Executed 100000 pipe operations between two processes
    
         Total time: 0.851 [sec]
    
           8.514660 usecs/op
             117444 ops/sec
    
  9. tonymet commented on Oct 6, 2026

    @tonymet
    Author

    WSL Kernel Mitigations Performance Benchmark Report

    Overview

    This report benchmarks the performance impact of CPU speculative execution mitigations (mitigations=on vs mitigations=off) in WSL v3.0.2 (Linux kernel 6.18.40.1-microsoft-standard-WSL2, 16 vCPUs).

    Tests were executed using the in-memory, side-effect-free test suite located at scripts/wsl-mitigations-testing/.


    Environment & Configuration

    • OS / Platform: Windows 11 / WSL v3.0.2 (Hyper-V VM)
    • Kernel: 6.18.40.1-microsoft-standard-WSL2
    • vCPUs: 16

    Kernel Command Lines

    • Mitigations ON (Baseline):
      initrd=\initrd.img WSL_ROOT_INIT=1 panic=-1 nr_cpus=16 hv_utils.timesync_implicit=1 printk.devkmsg=on page_reporting.page_reporting_order=5 swiotlb=force hv_pci_swiotlb=67108864 hv_storvsc.storvsc_max_hw_queues=4 console=hvc0 debug pty.legacy_count=0 WSL_ENABLE_CRASH_DUMP=1
      
    • Mitigations OFF (Target):
      initrd=\initrd.img WSL_ROOT_INIT=1 panic=-1 nr_cpus=16 hv_utils.timesync_implicit=1 printk.devkmsg=on page_reporting.page_reporting_order=5 swiotlb=force hv_pci_swiotlb=67108864 hv_storvsc.storvsc_max_hw_queues=4 console=hvc0 debug pty.legacy_count=0 WSL_ENABLE_CRASH_DUMP=1 quiet loglevel=0 audit=0 mitigations=off vsyscall=none
      

    Benchmark Commands

    The tests were executed using native perf bench tools:

    # 1. Syscall Entry/Exit latency & throughput
    perf bench syscall basic -l 10000000
    
    # 2. Pipe IPC context switching (two-process ping-pong)
    perf bench sched pipe -l 100000
    
    # 3. Multi-process scheduler contention (hackbench)
    perf bench sched messaging -g 20 -l 1000
    
    # 4. Futex lock wake latency
    perf bench futex wake -t 16 -w 1
    
    # 5. Memory bandwidth baseline (control check)
    perf bench mem memcpy -l 1GB

    Executive Summary of Results

    Benchmark Metric Mitigations ON Mitigations OFF Difference (OFF vs ON) Improvement Ratio
    Syscall Basic Throughput 5,353,135 ops/s 14,798,678 ops/s +176.45% ▲ 2.76x faster
    Syscall Basic Latency 0.1868 µs/op 0.0676 µs/op -63.83% ▼ 2.76x lower latency
    Sched Pipe Throughput 123,159 ops/s 217,736 ops/s +76.79% ▲ 1.77x faster
    Sched Pipe Latency 8.1196 µs/op 4.5927 µs/op -43.44% ▼ 1.77x lower latency
    Sched Messaging Duration (hackbench) 1.682 s 0.997 s -40.73% ▼ 1.69x faster
    xychart-beta
        title "Throughput Comparison: Mitigations ON vs OFF (ops/sec in Thousands)"
        x-axis ["Syscall Basic (x10k)", "Sched Pipe (k)"]
        y-axis "Operations / sec" 0 --> 1600
        bar [535, 123]
        bar [1480, 218]
    
    Loading

    (Blue = Mitigations ON, Orange = Mitigations OFF)


    Detailed Benchmark Breakdown

    1. Basic Syscall Entry/Exit (perf bench syscall basic)

    • Metric: 10,000,000 repeated getppid() system calls.
    • Result:
      • ON: 5,353,135 ops/s (0.1868 µs/op)
      • OFF: 14,798,678 ops/s (0.0676 µs/op)
    • Insight: Raw syscall transitions show a +176.45% throughput gain (nearly 3x throughput). Speculative execution barriers (KPTI page table flipping, entry/exit speculation barriers) represent the single largest overhead tax inside WSL.

    2. Sched Pipe IPC (perf bench sched pipe)

    • Metric: 100,000 ping-pong pipe data transfers between two processes.
    • Result:
      • ON: 123,159 ops/s (8.12 µs/op)
      • OFF: 217,736 ops/s (4.59 µs/op)
    • Insight: Pipe IPC throughput jumps by +76.79%. This reflects the combined cost of context switching, indirect branch speculation barriers (IBPB/STIBP), and pipe buffer read/write syscalls.

    3. Sched Messaging / Hackbench (perf bench sched messaging -g 20 -l 1000)

    • Metric: 20 groups of 20 sender/receiver pairs (400 processes total) exchanging 1,000 messages.
    • Result:
      • ON: 1.682 seconds total time
      • OFF: 0.997 seconds total time
    • Insight: Multi-process scheduling contention drops by 40.73% in total wall-clock runtime, demonstrating that realistic multi-process workloads (such as build systems, Node.js worker pools, and test runners) benefit heavily from disabling mitigations.

    CPU Vulnerability Status Diffs

    Disabling mitigations altered the guest kernel's security posture as follows:

    Vulnerability Mitigations ON Mitigations OFF
    spectre_v1 Mitigation: usercopy/swapgs barriers and __user pointer sanitization Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers
    spectre_v2 Mitigation: Retpolines; IBPB: conditional; IBRS_FW; STIBP: always-on; RSB filling; PBRSB-eIBRS: Not affected; BHI: Not affected Vulnerable; IBPB: disabled; STIBP: disabled; PBRSB-eIBRS: Not affected; BHI: Not affected
    spec_store_bypass Mitigation: Speculative Store Bypass disabled via prctl Vulnerable
    spec_rstack_overflow Vulnerable: Safe RET, no microcode Vulnerable
    tsa Vulnerable: No microcode Vulnerable
  10. tonymet commented on Nov 24, 2026

    @tonymet
    Author

    Still affecting WSL v 3.0.5 . see #41827 for more test results

    WSL version: 3.0.5.0
    Kernel version: 6.18.58.1-1
    WSLg version: 1.0.79
    MSRDC version: 1.2.7391
    Direct3D version: 1.611.1-81528511
    DXCore version: 10.0.26100.1-240331-1435.ge-release
    Windows version: 10.0.26320.10022
    
  11. tonymet commented on Nov 24, 2026

    @tonymet
    Author

    Hayden Barnes (@sirredbeard) since this has been repro'ed in #41827 can we see about escalating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kconfig

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions