1

I recently cloned a GitHub repository into my Windows 10 PC. As the code was mostly in C++ it had to be compiled and built to be able to generate a working GUI.
To do so I used WSL, which allowed me to compile, build and run (using CMake), but as WSL doesn't have it's own display I had to use an X11 program (VcXsrv) for visualization. This last one seems to be making the interface rather slow, because the FPS indicator never goes above 15 and I'm told that the native build works at 60 FPS.

I'd like to know if there is a simple workaround that I can try from WSL to make it faster, as my other option is to try and learn Visual Studio.

The code run in WSL Ubuntu 20.04 is:

git clone --recurse-submodules https://github.com/nmwsharp/vector-heat-demo.git
cd vector-heat-demo
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
export DISPLAY=localhost:0
./bin/vector_heat /path/to/your/mesh.obj 

And on the Windows side, I'm using VcXsrv settings: multiple windows, display 0, start no client, disable native opengl, from this answer.

CRuizH
  • 70
  • 1
  • 10
  • Do you have ```WSL2``` or ```WSL``` ? Did you tried VSCode with WSL Connection? – Kraego Sep 13 '21 at 18:45
  • @kraego I'm using WSL. WSL2 didn't work with VcXsrv when I tried to use it (it couldn't recognize the display). And no, I haven't tried VSCode with WSL yet. Does VSCode have a display of its own? I'm not sure how that would solve the issue otherwise. – CRuizH Sep 15 '21 at 17:55

1 Answers1

1

The reason why it’s slow is the architecture of wsl1. See below.

Comparison WSL1 and WSL2

  • In WSL1 linux kernel is kind of emulated, there is a software layer which maps linux syscalls to windows syscalls (this means you loose some time when accessing devices) which will lead to low FPS in your case.
  • In WSL2 microsoft created a hypervisor on which win10 and the microsoft linux kernel is running (your ubuntu, debian, ... runs on top of that), which means WSL2 is way faster because of skipping that translation layer (more information can be found here: differences WSL1 & WSL2
  • I've also created a guide how to use it with X11 see here (which works for me)

VSCode connect to WSL

  • it’s just for coding not for running your gui
  • In this scenario a headless VSCode (Server) is started in your WSL. The VSCode on your Windows will than connect to this instance (meaning you'll have the linux filesystem + gcc toolchain available.
  • VSCode Remote WSL Documentation from microsoft
Kraego
  • 2,978
  • 2
  • 22
  • 34
  • I got an error trying to use your WSL2 method: `GLFW emitted error: GLX: Failed to create context: GLXBadFBConfig GLFW emitted error: Cannot set swap interval without a current OpenGL or OpenGL ES context Segmentation fault` – CRuizH Sep 20 '21 at 19:50
  • Maybe this could help you: https://stackoverflow.com/a/66506098/11473934 – Kraego Sep 20 '21 at 21:21
  • I had to run `sudo apt install mesa-utils` first, but that made it work with WSL2. Unfortunately speed issues remain and it is almost as slow as in WSL(1). – CRuizH Sep 21 '21 at 01:10
  • Okay, sounds like WSL1 wasn‘t the bottleneck… sorry i couldn’t help – Kraego Sep 21 '21 at 05:22