禁用核心如何影响正在运行的进程?

发布于 2024-07-08 12:59:56 字数 188 浏览 6 评论 0原文

我在 Macbook Pro 上安装了这个应用程序,它允许我禁用 CPU 上的核心。 这让我想知道:禁用核心如何影响正在运行的进程?

产生影响

  • 我还感兴趣的是,禁用某个核心是否会对以下电池寿命
  • ? 当处理器通常使用两个核心的 40% 以下时,性能是否会提高

I have this application installed on my Macbook Pro that allows me to disable a core on my CPU. It got me wondering: How does disabling a core affect the running processes?

I am also interested if disabling a core has an affect on the following

  • Battery Life
  • Heat generation
  • Increased performance when the processor would normally be using less than 40% of both cores?

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

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

发布评论

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

评论(5

£冰雨忧蓝° 2024-07-15 12:59:57

有趣的问题。 这有点涉及。 您并没有非常具体地了解“禁用核心的应用程序”的含义以及它的作用,但我从您的问题和对另一个人的评论中推测,该应用程序正在以操作系统内核友好的方式禁用核心。

因此,通常当 OS X 运行时,有许多不同的可能的线程/进程(从这里开始我会说线程)在调度程序中竞争 CPU 资源。 当 Core 2 Duo 处理器的两个核心均启用时,内核能够同时运行两个线程 - 轮换两个核心来完成需要运行的所有任务。 当您禁用其中一个核心时,内核将恢复为仅将工作分派给单个核心。 当然,这不会改变需要完成的工作量……它只会将您的潜在执行性能降低一半。

如果您的核心平均忙碌率低于 50%,您可能会认为这并不重要,对吧? 嗯,在很多情况下这确实很重要,原因是执行东西的延迟。 如果任何时候只有一个线程可运行,那么第二个核心总是无用的,即使它仍然启用。 然而,在任何两个或多个线程可运行的情况下......都可以利用两个核心,如果其中一个核心被禁用,那么第二个线程上要完成的工作甚至无法开始,直到上一个线程为止执行一段时间然后被换出。 假设两个线程需要完成相同的工作,显然与双核情况相比,第二个线程完成所需的时间是双核情况的两倍。 您可能没有注意到这一点,具体取决于我们在这里讨论的工作量,但显然延迟(响应能力)至少在理论上将减少一半。 显然,随着系统加载越来越多需要运行的线程或有更多工作要做的线程,一切都在以一半的速度运行(实际上)将变得越来越明显。

这一切都很简单。

那么这对于散热和电池寿命来说意味着什么?

你是否在这方面领先......因为事实上,尽管你可能倾向于认为你每单位时间消耗的功率是原来的一半,但实际上完成工作的时间是原来的两倍。

这里的结论是,禁用内核最终对整体电池寿命的影响非常小(如果有的话),因为操作系统和 CPU 已经协同工作来降低时钟速度并有效关闭不需要的内核。 也就是说,让一个核心处于等待状态,以便在需要时使用,实际上几乎没有任何开销。 事实上,仅使用一个核心的系统实际上可能具有更短的电池寿命,因为主板上的所有其他设备必须保持活动更长时间,因为 CPU 需要更长的时间才能完成所需的工作。

相对于散热来说,效果是类似的。 显然,仅使用一个核心,以瓦特为单位的峰值散热量就会大幅降低......因为两个核心中只有一个实际上处于活动状态。 然而,同样,该核心将运行更长时间,并且净总能量输出(焦耳或瓦秒)将大致相同......这也是为什么您的电池寿命在一个核心与两个核心的情况下基本上不受影响的原因。

Interesting question. This gets somewhat involved. You were not super specific about exactly what you mean by "application that disables a core" and exactly what it does, but I presume from your question and the comment to another that this application is disabling the core in a OS kernel friendly way.

So, normally when OS X is running, there are many different possible threads/processes (I'll say threads from here on out) that are competing for CPU resources in the scheduler. When both cores of your Core 2 Duo processor are enabled, the kernel has the ability to be running two threads simultaneously - rotating both cores through everything that needs to run. When you disable one of the cores, the kernel is going to drop back to only dispatching work to a single core. Of course, this doesn't change the amount of work that needs to get done....it just cuts your potential execution performance in half.

You might not think this matters if your cores were averaging less than 50% busy, right? Well, it does matter in many circumstances and the reason is latency to execute stuff. If there is only one thread runnable at any time, then the second core is always useless, even if it still enabled. However in any situation where two or more threads become runnable....it is possible to take advantage of both cores and if one of them is disabled then the work to be done on the second thread can't even start until the previous thread executes for awhile and then gets swapped out. Assuming two threads with equal work to be done, clearly it is going to take twice as long for the second thread to get to completion compared to the dual core case. You may not notice this, depending how much work we are talking about here, but clearly the latency (responsiveness) at least in theory is going to be cut in half. Clearly, as the system loads up with more and more threads that need to run or threads that have more work to do, it will become progressively more obvious that everything is running - in effect - at half speed.

That was all pretty straight forward.

So what does this mean relative to heat dissipation and battery life?

Do you come out ahead here or not....because point in fact while you might be inclined to think you are drawing half as much power per unit time, work is in fact taking twice as long to complete.

The conclusion here is that disabling a core, in the end, will have very little if any impact on overall battery life because the OS and the CPU are already working together to throttle back the clocks and effectively shutdown a core that is not needed. That is, there is really little to no overhead in having a core in the waiting ready to be used when you need it. In fact, a system might actually have shorter battery life with only one core is used because all the other devices on the motherboard have to stay active longer as the CPU is taking longer to get the needed work done.

Relative to heat dissipation, the effect is similar. Clearly, the peak heat dissipation in terms of WATTS is dramatically cut down with only one core....because only one of two cores is actually active. However, again, that core will be running longer and the net total energy output (JOULES or WATT SECONDS) will be approximately the same...which is again why your battery life is largely unaffected in the one core vs. two core case.

咆哮 2024-07-15 12:59:57

我假设当你“禁用”核心时,你实际上是在告诉 OS X 不再并行处理。

我还假设操作系统足够聪明,可以在禁用进程后移动进程:)

但是,我认为您不会真正看到功耗或电池寿命的巨大改进,但这是一个猜测- CPU 仍在通电,只是其中一部分未被访问。

另外,这只是一个理论问题,除非注意保持热属性恒定,否则仅运行一个核心是否会增加 CPU 烧坏的可能性? 只是一个想法。

I'll presume that when you "disable" the core, you're really telling OS X to no longer process in parallel.

I'd also presume that the OS is clever enough to move processes around after you've disabled them :)

I don't think, however, you'd really see a huge improvement on power consumption or battery life, but it's a guess - the CPU is still getting power, just part of it isn't being accessed.

Also, and this is merely a theoretical question, mightn't running only one Core increase the likelihood of the CPU burning-out, unless care is taken to keep the thermal properties constant? Just a thought.

傲性难收 2024-07-15 12:59:57

它不会真正影响您正在运行的进程。 调度程序将从核心中清除正在运行的进程,并且不会为其指定另一个进程。
现在你的调度程序只需要找到一个好的策略来将进程公平地分配给剩余的核心。

  1. 电池:边际
  2. 热差:可以忽略不计......2x40%负载
  3. 不存在或稍差
    • 更糟糕的是,因为现在所有进程都必须切换到唯一的核心
    • 在一个进程(及其上下文!)可以一直停留在一个核心上之前
    • 所以这会增加 I/O ...而您唯一的核心必须等待它(刷新 TLB 和页表)

It won't really affect your running processes. The scheduler will clear the running process from the core and just won't dedicate another proccess to it.
And now your scheduler just have to find a nice strategy to find a fair allocation of the processes to the remaining core.

  1. battery: marginal
  2. heat-diff: negligible ... with the 2x40%-load
  3. nonexistent or slightly worse
    • worse because now all processes have to be switched over the one and only core
    • before one process (and his context!) could have stayed all the time on one core
    • so this will add I/O ... and your only core has to wait for it (flushing the TLB and page table)
何处潇湘 2024-07-15 12:59:57

我不知道功耗,但我希望你能节省一些余量。 这取决于 MBP 中 CPU 使用的电量百分比。

至于对原始处理能力的影响,这取决于您正在运行的应用程序的性质。 大多数应用程序并不是为利用多核而设计的,尽管大多数高端应用程序都是如此。 因此,如果您使用 Photoshop 或视频编辑软件,那么在性能瓶颈是 CPU(而不是网络 IO 或磁盘 IO)的情况下,您会注意到峰值性能显着降低。

I don't know about power consumption, but I expect you would save some margin. This depends upon the percentage of power used within the MBP by the CPU.

As for impact on raw processing power, it depends upon the nature of the applications you're running. Most applications aren't designed to utilise multiple cores, although most top-end apps are. So, if you're using Photoshop or video editing software then you'll notice a significant peak performance reduction in cases where the performance bottleneck is the CPU (and not network IO or disk IO).

暮年慕年 2024-07-15 12:59:56

禁用核心如何影响正在运行的进程?

事实并非如此,除非你使用的程序写得非常糟糕。 操作系统调度程序将收到处理器不再可用的警报,并且将停止将进程调度到该处理器中。 将进程从“运行”变为“等待”需要几微秒的时间,因此切换看起来是瞬时的。 当另一个核心变得可用并且优先级允许时,该进程将继续在另一个核心上运行。

禁用核心如何影响电池寿命

它将产生可测量但不显着的影响 - 在某些情况下它会增加。 换句话说,您不会看到能源使用量下降超过 5%,因为现代处理器已经采用了积极的节能技术。 处理器不会运行空闲循环 - 当没有进程准备运行时它们会停止。 如果整体系统负载较低,操作系统会减慢处理器速度而不是停止它们,这具有类似的节省效果。

在某些非常具体的使用场景中,由于操作系统如何使用处理器(更多的任务切换,这会导致性能降低和处理器利用率更高),能源使用量将会增加。

禁用核心如何影响热量产生

与功率一样,它是可以测量的,但如果不仔细测量则不会明显。 同样,处理器已经具有出色的功率控制,并且无论有多少处理器处于活动状态,都会调节时钟、电压和处理器空闲以匹配负载。

禁用核心对性能有何影响(假设处理器使用的两个核心均少于 40%)

进程非常“高峰”。 当您按下某个键或移动鼠标时,它会启动数十个等待进程,并希望在很短的时间内达到 100%。

通过强制处理器一次运行一个而不是并行运行,是的,总体平均使用率只有 80%,但它会感觉滞后,不仅因为大量等待进程,而且还因为每次任务切换进程发生更改(由于优先级、正在完成或中断等),处理器加载操作系统任务,然后运行调度程序,然后调度程序加载下一个任务。

您将一个处理器上的任务切换负载加倍,这意味着您将更频繁地运行操作系统代码(调度程序、事件管理器等)以满足需求。

这是一种浪费,而且性能下降实际上可能是显而易见的。 例如,如果操作系统可以选择以正常速度的 40% 运行两个处理器,则不一定需要执行这项额外的工作。

-亚当

How does disabling a core affect the running processes?

It doesn't, unless the program you're using is phenomenally badly written. The OS scheduler will be alerted that the processor is no longer available, and will simply stop scheduling processes into that processor. Putting a process from "running" into "waiting" take microseconds, so the switch will appear instantaneous. The process will continue running on the other core as it becomes available and priority allows.

How does disabling a core affect battery Life

It will have a measurable but not significant effect - in some cases it will increase. In other words, you shouldn't see more than perhaps 5% decrease in energy usage as modern processors already employ aggressive power saving techniques. Processors don't run idle loops - they stop when there's no process ready to run. If the overall system load is low, the OS slows the processors down rather than stopping them, which has a similar savings effect.

In certain, very specific, usage scenarios, energy usage will go up due to how the OS uses the processors (more task switching, which leads to lower performance and higher processor utilisation).

How does disabling a core affect heat generation

As with power, it will be measurable, but not noticeable without careful measurement. Again, the processor already has exceptional power control and will moderate the clocks, voltage, and processor idle to match the load, regardless of how many processors are active.

How does disabling a core affect performance (assuming the processor is using less than 40% of both cores)

Processes are very 'peaky.' When you press a key or move the mouse it kicks off dozens of waiting processes, and wants 100% for a very short period of time.

By forcing the processor to run them one at a time instead of parallel, yes the overall average usage is only 80%, but it will feel laggy not just due to a lot of waiting processes, but also due to the task switching - every time a process is changed (due to priority, or it being finished, or interrupt, etc) the processor loads the OS task, which then runs the scheduler, which then loads the next task.

You're doubling the task switching load on one processor, which means you're running the OS code (scheduler, event manager, etc) much more frequently to keep up with the demand.

This is wasteful, and the performance decrease may actually be noticeable. This additional work would not necessarily need to be performed if the OS had the option of running both processors at 40% of their normal speed, for instance.

-Adam

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