WSL、WSL2与Ubuntu性能大PK
<p>科技媒体 Phoronix 对 Windows 10 May 2020 中 WSL 和 WSL 2 的性能进行了测试,参与测试的发行版为 Ubuntu 20.04 on WSL/WSL2 ,以及 Ubuntu 20.04 LTS,均被安装在除 Windows 之外的电脑裸机中。</p>
<p>
本次测试使用的电脑硬件设备是 Intel Core i9 10900K (Comet Lake) CPU,搭配 2 x 8GB DDR4-3200 的内存、三星 970 EVO 250GB NVMe SSD 硬盘、技嘉 Z490 AORUS MASTER 和 Radeon RX 5700 XT 显卡。具体的测试环境如下:</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/2166d0206a5adb5d4e32f7b2252b65a8.jpg"></p>
<p>
通过 Phoronix 测试套件,共进行了几十项不同的基准测试。测试结果如下:</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/776928ad9d5bdfd83606f2d2daa3cc17.jpg"></p>
<p>
从上图的测试结果可以看到,在进行繁重的 CPU 工作负载时,如机器学习 LC0 国际象棋基准测试和 NAMD 测试等,WSL2 综合表现是最好的。在 NAMD 测试中,WSL 与 WSL2 的性能一样,比 Ubuntu 还稍快一些。在 LC0 测试中,WSL2 性能更快。尤其是 LC0 测试中使用 Eigen 后端的场景,WSL2 的性能甚至略微领先于 Ubuntu 本身——可能是由于 Windows 提供了更好的电源管理行为或类似行为。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/f8292557cf32c5fd7179ca73d6107200.jpg"></p>
<p>
上图是测试一些 Java 工作负载的结果,这里明显看出了 WSL2 的性能比 WSL 更好。测试使用的是 OpenJDK,性能最好的是裸机版本的 Ubuntu 20.04。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/64bdf15745057c5b4925dd5223a688b9.jpg"></p>
<p>
在使用部分应用程序进行测试时,罕见地看到 WSL 的性能比 WSL2 更好。不过从这项测试的总体结果来看,WSL/WSL2 的性能也非常接近裸机版本 Ubuntu 20.04 的性能,三者相差无几。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/a4281b19f3c1410f226c05c11b0ffcbf.jpg"></p>
<p>
上面这几项测试也看不出三者之间的性能差距,因为整体来看都非常不错。但如果细看的话,裸机版本的 Ubuntu 20.04 还是略占上风。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/156bff468922b405793eff91ce9171fd.jpg"></p>
<p>
这里的测试结果显示,使用另外一些程序测试时,WSL2 的性能确实略微超过了 Ubuntu 20.04 本身。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/e7e9bba1f156dc4396f2adab3bb05074.jpg"></p>
<p>
上图的测试结果反映了在 I/O 操作方面的性能。这正是 WSL 的短板,其性能较差的地方刚好包括 I/O 操作,刚问世时这个缺点曾被不少用户诟病。到了 WSL2,它采用了更类似于虚拟机的方式,使得 I/O 吞吐量大大提升。WSL2 的代码编译性能甚至与 Ubuntu 20.04 相差无几。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/dcc025b8a183e854e17a9ee3c6dc243b.jpg"></p>
<p>
对于可能因为某种原因而不得不使用 Windows 10 的用户来说,WSL2 总体上至少在每个工作负载中都表现得 "足够好”。即使是在各种内核 micro-benchmarks 测试中,WSL2 也基本上与 Ubuntu 20.04 及其 Linux 5.4 内核持平。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/b7e36edb0d0d693a25eabdb833477b00.jpg"></p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" src="https://zhuji.jb51.net/uploads/img/20230519/a27e9266e557aac6f57d11150d7f14ad.jpg"></p>
<p>
上图反映的是 socket activity 和上下文切换方面的性能,WSL2 由于架构的改变,其性能比 WSL 和 Ubuntu 20.04 都好很多。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" border="0" src="https://zhuji.jb51.net/uploads/img/20230519/521f6bbde80baf7b039e2955a73cd4ec.jpg" width="600"></p>
<p>
上图反映了在大多数纯 CPU bound 的工作负载场景中,比如渲染器,在 WSL/WSL2 上都表现得十分出色。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" border="0" src="https://zhuji.jb51.net/uploads/img/20230519/e5f4e96c2b9faa897f0bcac0e906118b.jpg" width="600"></p>
<p>
Facebook 的 RocksDB 数据库在 WSL2 和 Ubuntu 20.04 LTS 之间的性能表现相似,而在 WSL 中,糟糕的 I/O 性能导致了糟糕的结果。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" border="0" src="https://zhuji.jb51.net/uploads/img/20230519/cc95638ed8d99343448c54d8cc0cfbc5.jpg" width="600"></p>
<p>
即使是在 WSL2 中使用 Git,也比 WSL 有了巨大的速度提升。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" border="0" src="https://zhuji.jb51.net/uploads/img/20230519/9989e5451743fa60efbffd5337ad10aa.jpg" width="600"></p>
<p>
本次测试总共包含 69 项测试。Ubuntu 20.04 LTS 赢得了 60% 的测试,这就意味着出现了一个有趣的结果,40% 的测试中 WSL/WSL2 比 Ubuntu 20.04 LTS 本身更快,尽管通常是以微弱的优势胜出。</p>
<p align="center">
<img style="max-width:100%!important;height:auto!important;"title="WSL、WSL2与Ubuntu性能大PK" alt="WSL、WSL2与Ubuntu性能大PK" align="" border="0" src="https://zhuji.jb51.net/uploads/img/20230519/0b89a1f6f537c28ac75dc2ab6d6039be.jpg" width="600"></p>
<p>
当将三者的 69 项基准测试结果的几何平均值进行比较时,WSL2 比 WSL 的性能高出大约 21%,而 Ubuntu 20.04 的速度仅快 8%。WSL2 由于解决了 WSL 的主要瓶颈,拥有了更快的 I/O。更值得关注的是,WSL2 的性能已非常接近 Ubuntu 本身的性能。通过 OpenBenchmarking.org 查看全部 69 项基准测试。</p>
頁:
[1]