超线程对编译器性能的影响?

发布于 2024-08-17 04:15:14 字数 292 浏览 5 评论 0原文

假设我们想要尽快编译一个大型项目(例如 GCC 或 Linux 内核)。具有超线程功能的 CPU(例如 Intel Core i7)在启用或禁用超线程的情况下运行编译器的速度是否会更快?是否有任何已发布的基准测试可以对此进行测试?

我对超线程的理解是每个核心可以从两个(或更多进程)中选择指令。这通常会使核心更加高效,因为功能单元不太可能闲置。然而,由于在同一核心上运行的进程共享缓存等资源,并且可能会相互干扰,因此可能会造成性能损失。性能是否真正提高取决于工作负载。

那么对于编译器工作负载来说,性能是否会提高?如果是这样,幅度是多少?

Say we want to compile a large project (say GCC or the Linux kernel) as fast as possible. Does a CPU with hyperthreading capability (say an Intel Core i7) run the compiler any faster with hyperthreading enabled or disabled? Are there any published benchmarks that test this?

My understanding of hyperthreading is that each core can select instructions from two (or more processes). This usually makes the core more efficient since it's less likely that functional units will be idle. However, there's potential for a performance penalty since processes running on the same core share resources such as cache and may interfere with one another. Whether or not performance actually increases depends on the workload.

So for a compiler workload, does performance increase? If so, by how much?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一绘本一梦想 2024-08-24 04:15:14

上编译 coreutils-8.4

在启用 HT 的 Ubuntu 8.04 x86 Intel Atom 1.6 GHz

~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null

real    2m33.375s
user    2m22.873s
sys     0m10.541s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null

real    1m54.707s
user    3m26.121s
sys     0m13.821s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null

real    2m33.372s
user    2m22.753s
sys     0m10.657s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null

real    1m54.851s
user    3m26.145s
sys     0m13.685s
~/coreutils-8.4$

:因此超线程将运行时间减少到 75%,相当于处理能力提高了 33%。 (我运行了两次,以确保所有内容都在内存缓存中。)

这是一个控制实验,表明单独使用 make -j2 并不能提高在 Ubuntu 8.04 x86 上编译 coreutils-8.4 的速度

单核 Core 2 四核 2.5 GHz 虚拟机(无 HT):

~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null

real    0m44.453s
user    0m38.870s
sys     0m5.500s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null

real    0m45.131s
user    0m40.450s
sys     0m4.580s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null

real    0m44.621s
user    0m39.090s
sys     0m5.340s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null

real    0m45.165s
user    0m40.390s
sys     0m4.610s
~/coreutils-8.4$

Compiling coreutils-8.4 on Ubuntu 8.04 x86

Intel Atom 1.6 GHz with HT enabled:

~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null

real    2m33.375s
user    2m22.873s
sys     0m10.541s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null

real    1m54.707s
user    3m26.121s
sys     0m13.821s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null

real    2m33.372s
user    2m22.753s
sys     0m10.657s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null

real    1m54.851s
user    3m26.145s
sys     0m13.685s
~/coreutils-8.4$

So Hyper-Threading reduces the run time to 75%, which is equivalent to 33% more processing power. (I ran them twice to ensure that everything is in the memory cache.)

And here is a control experiment to show that make -j2 alone does not improve the speed for compiling coreutils-8.4 on Ubuntu 8.04 x86

Single-core Core 2 Quad 2.5 GHz VM (no HT):

~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null

real    0m44.453s
user    0m38.870s
sys     0m5.500s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null

real    0m45.131s
user    0m40.450s
sys     0m4.580s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make > /dev/null

real    0m44.621s
user    0m39.090s
sys     0m5.340s
~/coreutils-8.4$ make clean > /dev/null
~/coreutils-8.4$ time make -j2 > /dev/null

real    0m45.165s
user    0m40.390s
sys     0m4.610s
~/coreutils-8.4$
嘿咻 2024-08-24 04:15:14

这完全取决于编译器是否被编写为多线程。如果是,那么超线程肯定会加快速度,因为操作系统可以将编译器线程的不同部分调度到不同的内核上。我同意 Ken 的观点,即编译通常比处理密集型更受 I/O 限制,因此拥有快速硬盘驱动器比具有 100 个内核的快速处理器更为必要。

It all depends on if the compiler is written to be multi-threaded or not. If it is, then definitely hyperthreading speeds things up a bit since then the OS can schedule different parts of the compiler's threads onto different cores. I agree with Ken that compilations generally are more I/O bound than processing intensive, so having a speedy hard-drive would be more of a necessity than a speedy processor with 100's of cores.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文