简体   繁体   English

如何从.Net中的超线程中获得最大收益

[英]How to make maximum benefit from Hyper-Threading in .Net

Not sure if that is even possible in a managed language, but is it possible to actually make an application perform better in the presence of hyper threading ? 不确定在托管语言中是否甚至可以实现,但是在超线程存在的情况下是否可以实际使应用程序运行得更好?

Is there something specific that can be done in the code ? 是否有某些特定的东西可以在代码中完成? , maybe some functions run better than other in HT environments ? ,也许某些功能比HT环境中的其他功能运行得更好?

I know that to benefit from multi-threading, all that is needed is to spawn new threads to perform heavy cpu tasks, but I am not sure what is required for HT ? 我知道要从多线程中受益,所需要的就是生成新线程以执行繁重的cpu任务,但我不确定HT需要什么?

Depends a lot on the actual hardware you have. 取决于您拥有的实际硬件。 Read Be aware: To Hyper or not to Hyper for a more in dept analysis. 阅读注意:要超级或不要超级以获得更多的部门分析。 Slava's point in the link is that in HT the virtual cores share the cache and a the virtual core workload can trash the cache of the 'main' core and, even though it can do at best some 20% of workload compared with the main core, becuase it evicts the hot cache of the main core, it cause the main core to stall and overall results in worse performance than w/o HT. Slava在链接中的观点是,在HT中,虚拟核心共享缓存,虚拟核心工作负载可能会破坏“主”核心的缓存,即使它与主核心相比最多可以完成约20%的工作量,因为它驱逐主核心的热缓存,它导致主核心停滞,整体导致比没有HT的性能更差

But a lot of things have changed since the article was posted, HT post Nehalem is significantly better. 但自文章发布以来,很多事情都发生了变化,HT后Nehalem明显变得更好。

I know that to benefit from multi-threading, all that is needed is to spawn new threads to perform heavy cpu tasks 我知道要从多线程中受益,所需要的只是生成新线程来执行繁重的cpu任务

That is quite a naive view. 这是一个很天真的观点。 You must read Rick Vicik articles on high performance windows programs (they apply to managed apps too) and you must absolutely understand CPU Caches and Why You Care . 您必须阅读有关高性能Windows程序的Rick Vicik文章 (它们也适用于托管应用程序),您必须完全了解CPU缓存和您关心的原因

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM