My primary laptop is a Lenovo x250, with an Intel i7-5600U CPU, 16GB of RAM, a 512GB Transcend SSD, and a 2TB Samsung SSD. Let’s run some benchmarks on the CPU, Memory, Disk, and Network.
We’ll first run each test in Ubuntu running natively on the hardware, and then reboot, and run the same benchmarks on the same machine running Ubuntu on Windows.
sudo apt install sysbench iperf
To execute our CPU benchmark, we ran the following:
sysbench –num-threads=4 –test=cpu run
And, we see almost identical results! Basically 2.8 seconds to run 10,000 CPU instructions, in both cases (Ubuntu on Windows was ever so slightly faster, in fact, in these runs). For CPU bound workloads, Ubuntu on Windows should perform just as well as Ubuntu running natively on hardware:
To execute our Memory benchmark, we ran the following:
sysbench –num-threads=4 –test=memory run
Here, we’re moving 100G of data through memory. Native Ubuntu was able to move data through memory at 4,253 MB/s, while Ubuntu on Windows worked at 2,309 MB/s. This difference exposes a bit of a difference in the IO performance of the two systems. When dealing in heavy IO, Ubuntu on Windows does involve a bit more overhead.
For our disk performance test, we ran the following command:
dd if=/dev/zero of=testfile bs=1G count=1 oflag=dsync
Basically, we’re writing a 1GB file of zero’s, synchronously, to disk. Interestingly, the native Ubuntu test yields about 147 MB/s average write speed to disk, while the Ubuntu on Windows environment average 248 MB/s write speed to disk! How is that possible? Well, it’s a bit of trickery on the Windows part. The flag that we’re sending the dd command, oflag=dsync, is supposed to guarantee synchronous writes to disk — ensuring that every single byte is in fact written to disk and not cached in a buffer in memory. While we used that same flag on the Windows test, it seems that Windows doesn’t yet know what to do with that flag. It seems pretty clear that the Ubuntu on Windows writes are not entirely synchronous to disk.
Next, we’ll test network throughput. Specifically, we’re testing TCP bandwidth, using the iperf utility. I’m running an iperf server on an Ubuntu machine hardwired to a Gigabit network:
And we’re going to connect the iperf client from the native Ubuntu machine, and the Ubuntu on Windows machines:
The native Ubuntu machine averaged 935 Mbps, while the Ubuntu on Windows average 805 Mbps of bandwidth.
Linux Kernel Compilation
Finally, let’s take a tried and true performance benchmark at every Linux developer is familiar with — let’s build the kernel! The beauty of this sort of test is that it includes lots of CPU number crunching (compilation) as well as tons of disk reads (loading libraries and source files) and disk writes (binary output). It’s much closer to “real world” use cases than some of the academic benchmarks we’ve run above.
To reproduce these tests, you’ll need to:
sudo apt install git build-essential
git clone https://github.com/torvalds/linux.git
time make -j 4
Note that we’re using the default configuration for the build (defconfig), and we’re telling the compiler to use 4 CPUs (-j 4), since my Intel i7 is dual-core, hyperthreaded.
The native Ubuntu build took 5 minutes and 38 seconds, while the Ubuntu on Windows build took 8 minutes 47 seconds. I discussed this with the Windows developers and they suggested re-running the tests with Windows Defender disabled (just for testing — don’t do this long term, as Windows Defender detects malware). I wasn’t able to re-run the test in time to publish this post, but perhaps some of our motivated readers will reproduce the tests here and post their results!
The Windows Subsystem for Linux is nothing shy of amazing. Tremendous credit goes to the entire Microsoft team working on this technology. When coupled with Ubuntu, WSL really shines, bringing tens of thousands of open source utilities directly to the Windows desktop command shell.
From a performance perspective, CPU and Network bound processes will perform nearly identically in Ubuntu on Windows, as native Ubuntu on bare metal. For heavily cached disk IO operations, Ubuntu on Windows might even outperform native Ubuntu on bare metal. But for heavily randomized reads and writes, and memory heavy operations, Ubuntu on Windows does introduce a bit of overhead that might be noticeable in some developer workloads.
In any case, Ubuntu on Windows is a fantastic bridge between two worlds. Two worlds, that will learn a lot from one another. I’m proud to live in a new world where those two worlds are one.
Read previous articles in the series:
Learn more about Running Linux Workloads on Microsoft Azure in this on-demand webinar with guest speaker Ian Philpot of Microsoft. Watch Now >>