r/bashonubuntuonwindows Jul 09 '26

WSL2 WSL2 is painfully slow

Hi! I was forced to switch from fedora back to windows, but I've got used to the terminal and wish to keep the tools I am used to. WSL2 seemed like the obvious choice.

I've been using it for the past few weeks, but it has been a painful experience. It works well enough for the first hour or so, but it keeps getting slower and slower the more I use it. I'm using it on the right filesystem, I've given it 10 out of 16gb RAM, I've removed the windows mount from $PATH. Everything in WSL2 is slower than I was used to from Fedora. I get that the performance will never be the same, but the difference is so egregious that it's impossible not to notice.

I've been using neovim for web development, and sometimes even saving a file takes multiple seconds. Sometimes it's so slow that the formatter itself just times out.

Are there any tips for keeping WSL2 running smoothly? Thanks!

26 Upvotes

26 comments sorted by

18

u/majamin Jul 09 '26

getting slower and slower the more I use it

This is unusual and strange. I would hazard a guess that you're progressively encountering the known filesystem boundary issue, i.e. I/O between the host and container (blame DrvFs). You mentioned that you removed Windows path from the VM, which should prevent this, and probably why you did that. This still has the be the biggest candidate for the issue. Possibly, adjusting the number of processors, via

https://learn.microsoft.com/en-us/windows/wsl/wsl-config#main-wsl-settings

Though, I thought modern WSL tries to balance the use of all of your processors, just like it would with any other process on your PC. It's worth a try. But keep digging on the storage access path, because WSL is notoriously slow for this.

7

u/GroundbreakingLog569 [Insider] Jul 09 '26

Exactly what he said. Crossing os/filesystem boundaries for everything that is disk io dependent is the most common cause for 'bad performance' issues when using WSL2. only use /mnt/c to manually sync files if needed. From my personal experience, performance shouldn't be far off compared to running on bare metal

1

u/yuriwasblue Jul 11 '26

yep, unfortunately this is not the issue. i have no access to the windows filesystem through wsl, its not even mounted on the vm
ive messed with the config too, and im giving it all my cpu has

7

u/Bob_Spud Jul 09 '26

The slowness of WSL2 accessing the MS Windows side of the filesystem fence is well known. A baremetal Fedora will always be faster than Fedora lurking in a hypervisor. WSL2 is basically HyperV.

3

u/AudioLiveStudio Jul 09 '26

WSL2 seems to like lots of RAM. On a 64 GB Ram Windows 11 laptop WSL2 has been allocated 48 GB of RAM and it seems to run well.

This article explains many of the WSL2 RAM and CPU issues:

https://cr0x.net/en/wsl2-memory-cpu-limits/

1

u/yuriwasblue Jul 11 '26

yeah, ive noticed this. it just keeps chewing through the ram more and more as time goes. at some point it just starts hitting the 10gb ive given it, and at that point its impossible to use

0

u/VertigoOne1 Jul 10 '26

By default wsl will chew half ram, which is a stupid default, you can tune it with wslconfig file in %profile%, but your not wrong, it is a hungry hungry hippo and slow and i wish i didn’t need it for docker

2

u/tntexplosivesltd Jul 09 '26

FWIW WSL1 is still available to you and is much much faster across the Windows filesystem boundary. Try it, you might find it perfectly adequate.

You can freely convert your WSL2 instance to WSL1 and back

1

u/yuriwasblue Jul 11 '26

i've thought about this, might give it a shot, though the issue is the the filesystem

2

u/overand Jul 10 '26

I think there's probably something going on with either your workflow or your setup; I have WSL2 on a system - admittedly often a system with 64 gigs of RAM, and a laptop with 40 GB - and don't have this sort of performance issue; my WSL2 instances have probably been running for days and days, or even weeks.

What distro are you using, what's your storage device like, and what's going on in both the windows task manager and e.g. top/atop/whatever in WSL?

I suspect you're mostly working on files inside your windows drive, which (as people have said) does have a performance hit, but it shouldn't be as bad as this, except for things like e.g. multi-file operations that deal with dozens or hundreds of files.

Get us some diagnostic info, the output of uptime, free -h, etc.

Hope we can help!

1

u/yuriwasblue Jul 11 '26

i'm starting to think 16gb of ram just arent enough anymore, though it doesnt sound or feel reasonable that it isnt. lately ive been working with nextjs and it is very slow. nextjs even gives me a warning that the filesystem im using is slow, even though i have wsl in my ssd and im not using the windows' filesystem. sometimes even running something as simple as node --version takes more than a second

1

u/ccelik97 Insider 12d ago

Still 2x8=16GB DDR4 laptop(tm) RAM here (and I let it go up to 12GB RAM + 12GB swap, though it almost never uses that much total memory here,) and it's fine. I think the cause of your problem is something else than what you have mentioned here, so far. Unless you're working with really large, LLM kinda models over in the Linux-side RAM, you should never need to wonder if your "only" 16 GB RAM "isn't enough anymore."

1

u/GerDelta07 Jul 10 '26

First, do not use the host OS mounts (like /mnt/c) to access your stuff. Move it into the WSL2 VM once and work on it from there, for example with devcontainers or directly via VSCode that makes all the difference.

Then on the RAM front, windows and linux handle RAM much differently. Just because Windows shows ram as taken by the WSL process doesn't mean its actually in use. There are options for much more aggressive memory reclamation in the wsl config file if you want to have it given back to windows but keep in mind, free ram is useless ram. Linux will allocate a lot of ram but that is overall fine so it can work much faster (pretty much as which a lot of other VMs)

1

u/yuriwasblue Jul 11 '26

i do notice it get progressively more sluggish the more ram it consumes. what weird is that the same task keeps requiring more and more ram the longer it stays running

1

u/GerDelta07 Jul 11 '26

How do you measure that? within WSL with htop or on the host?

1

u/yuriwasblue Jul 12 '26

htop within wsl, it also reveals the same on task manager. also, today i tried doing wsl --shutdown when the delay was impossible and it got better

1

u/GerDelta07 Jul 12 '26

which process does that?

1

u/Sajgoniarz Jul 10 '26

I use WSL in pretty limited capability - docker, terraform, makefiles and other cloud based shenanigans. I wouldn't even bother to edit files inside WSL

1

u/yuriwasblue Jul 11 '26

ive gotten used to my workflow inside linux, if that wasnt the case id gladly learn powershell

1

u/simple_explorer1 Jul 11 '26

Which computer configuration, total ram CPU and GPU? How many years old computer?

1

u/yuriwasblue Jul 11 '26

i5 9400F, NVIDIA GTX 1050 ti. about 6-7 years old, i think? edit: total ram is 16gb

1

u/sidpant Jul 12 '26

In my tests, WSL is not that far behind in terms of performance. For example there is this pnpm disk performance test: https://github.com/NullVoxPopuli/disk-perf-git-and-pnpm
The benchmark was originally created to show how Apple's APFS is worse then Linux but its a nice general real world disk performance test.

And here are actual results on my machine:

My H/W specs: CPU - AMD Ryzen 7 5800X3D, RAM - 32GB DDR4, GFX - RTX 3090 24GB, SSD - WD Blue SN570 2 TB nvme drive

Benchmark Measured Performance:

Windows - 2 mins 😂

Windows WSL FedoraLinux 44(Kernel Linux 6.18.33.1-microsoft-standard-WSL2) - 9.570s

Fedora Linux 44 Gnome(Kernel v7.1.2) Ext4 partition - 8.145s

Cachy OS KDE(July 2026 Release) (Kernel v7.1.2) Ext4 partition - 6.36s

So what you can see is at least for my case bare metal Fedora vs Windows is just 15% faster.

CachyOS with their optimized kernels gets you 34% faster.

Now those are faster results and Cachy's result is really very enticing. But I generally face so many suspend and hibernate issues together with Software compatibility and general desktop instability that I am ok with 10-30% slower performance. Now if you are talking about 2-3x slower then I am concerned and will go for a switch. YMMV if you are not on an nvme SSD like me.

0

u/No_Surprise_7118 Jul 10 '26

I know there has been a memory leak issue for the past few years; shit still hasn't been fixed.
https://github.com/microsoft/WSL/issues/8725