简体   繁体   English

设置处理器对进程及其影响的亲和力

[英]Setting processor affinity for a process and its Effects

I am having an application which has a UI module and other supporting services. 我有一个具有UI模块和其他支持服务的应用程序。 These other services have memory leaks and other thread synchronization issues. 这些其他服务具有内存泄漏和其他线程同步问题。 Hence in some machines especially quad core, dual core machines the services crash every now and then. 因此,在某些机器(尤其是四核,双核机器)中,服务有时会崩溃。

I know the best way to fix this is to clean up the memory leaks and synchonization issues. 我知道解决此问题的最佳方法是清理内存泄漏和同步问题。

But as a work around we set the processor affinity for 2 of those services and observed that the crash did not happen after that. 但是,作为一项变通办法,我们为其中两个服务设置了处理器关联性,并观察到崩溃之后并没有发生。

Now my question is Will my services take a performance hit as i am limiting them to using only one processor? 现在我的问题是,由于我将服务限制为仅使用一个处理器,因此服务是否会受到性能的影响?

Edit 1: Note: These services are multi threaded. 编辑1:注意:这些服务是多线程的。

This certainly depends on whether those services rely on threading. 这当然取决于这些服务是否依赖线程。 If they are single-threaded you won't notice much difference. 如果它们是单线程的,则不会有太大区别。

In your case since services are multithreaded they might or might not experience perfomance penalty - this will depend on actual design, specifically on whether they rely on several threads being executed in parallel. 在您的情况下,由于服务是多线程的,它们可能会或可能不会遭受性能损失-这将取决于实际设计,特别是取决于它们是否依赖于并行执行的多个线程。

(might better fit serverfault.com) (可能更适合serverfault.com)

As the service creates multiple threads, most likely. 当服务创建多个线程时,最有可能。

Furthermore, it's response time might increase, even though the system is not under load. 此外,即使系统没有负载,它的响应时间也可能增加。 If the CPU you are bound to is busy with another thread, it has to wait for that thread to give up its time slice. 如果绑定的CPU忙于另一个线程,则必须等待该线程放弃其时间片。 This may become notable with many small requests processed by the (or a) thread. 对于(或)线程处理的许多小请求,这可能会变得很明显。

The perceived results may be subtle or devastating: You might run fine for a while, but go belly up when requests peak, dependent services (if any) may be slowed down. 感知的结果可能是微妙的或毁灭性的:您可能会运行一会儿,但是当请求达到高峰时,您就会忍受不了,依赖的服务(如果有)可能会变慢。

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

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