I have this subprocess.Popen() context manager:
with Popen(
args=command, shell=False, stdout=PIPE, bufsize=1, universal_newlines=True
) as process:
You will need to reevaluate that performance issue in Q3 2019, with WSL2.
See "Announcing WSL 2" from Craig Loewen
Changes in this new architecture will allow for: dramatic file system performance increases, and full system call compatibility, meaning you can run more Linux apps in WSL 2 such as Docker.
File intensive operations like
git clone
,npm install
,apt update
,apt upgrade
, and more will all be noticeably faster.
The actual speed increase will depend on which app you’re running and how it is interacting with the file system.
Initial tests that we’ve run have WSL 2 running up to 20x faster compared to WSL 1 when unpacking a zipped tarball, and around 2-5x faster when usinggit clone
,npm install
andcmake
on various projects.Linux binaries use system calls to perform many functions such as accessing files, requesting memory, creating processes, and more.
In WSL 1 we created a translation layer that interprets many of these system calls and allows them to work on the Windows NT kernel. However, it’s challenging to implement all of these system calls, resulting in some apps being unable to run in WSL 1.
Now that WSL 2 includes its own Linux kernel it has full system call compatibility.
Windows Subsystem for Linux is a bit rubbish. It's got many, many bugs and it's significantly slower than it needs to be. This is just another bug manifesting itself. Here are some possible bottlenecks:
wsl.exe
to launch the program (thanks RoadRunner!)systemd
(?)There's nothing wrong with your Python code that would make this slow.