wsl

filesystem performance is slow

workaround

Prefer ~/ over /mnt when filesystem performance is needed

wsl uses all the ram

yolo

Force linux to drop the page cache

echo 1 | sudo tee /proc/sys/vm/drop_caches

limit memory assigned to WSL2 VM

Create a %UserProfile%\.wslconfig file

[wsl2]
memory=6GB
swap=0
localhostForwarding=true

running windows applications in wsl

Controlled via /etc/wsl.conf:

[interop]
enabled=true
appendWindowsPath=false

More info

integrate beyond compare in wsl

Inside ~/.gitconfig:

[diff]
        tool = bcomp
[difftool]
        prompt = false
[difftool "bcomp"]
        path = "/mnt/c/Program\\ Files/Beyond\\ Compare\\ 4/BCompare.exe"
        cmd = "/mnt/c/Program\\ Files/Beyond\\ Compare\\ 4/BCompare.exe" "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)"
[merge]
        tool = bcomp
[mergetool]
        prompt = false
[mergetool "bcomp"]
        path = "/mnt/c/Program\\ Files/Beyond\\ Compare\\ 4/BCompare.exe"
        cmd = "/mnt/c/Program\\ Files/Beyond\\ Compare\\ 4/BCompare.exe" "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)" "$(wslpath -aw $BASE)" "$(wslpath -aw $MERGED)"

increase number of open files

Running into EMFILE errors because too many files open? (looking at you npm i):

mylimit=8000
sudo prlimit --nofile=$mylimit --pid $$; ulimit -n $mylimit
su $USER

increase number of open files

WSL2 clock drifts if left open when Windows sleeps. Fix with:

sudo hwclock -s