简体   繁体   English

Windows服务性能与Windows应用程序性能

[英]Windows Service performance vs. Windows Application performance

I'm developing a piece of software that needs to be run in high-performance and I'm wondering if it should be run as Windows-Service or regular Windows-Application. 我正在开发一款需要高性能运行的软件,我想知道它是否应该作为Windows服务或常规Windows应用程序运行。 The question is: is there any difference between both in terms of performance? 问题是:两者在性能方面有什么区别吗? means: will the OS scheduler give Windows-Service more CPU ticks than Windows-Application? 意思是:操作系统调度程序会给Windows服务比Windows应用程序更多的CPU滴答声吗?

To answer the question, see Description of Performance Options in Windows : 要回答该问题,请参阅Windows中的性能选项说明

You can use the performance options to set Windows be optimized for either foreground programs or background services. 您可以使用性能选项将Windows设置为针对前台程序或后台服务进行优化。 The assumptions are that background services are relatively few in number and would be more efficient with more CPU time, and that program servers or interactive programs on desktop computers would be more efficient with shorter time slices to allow them to be more responsive to keyboard input and to service more threads (many thousands on Terminal Services in Application Server mode. 假设后台服务的数量相对较少,并且随着CPU时间的增加,效率会更高;而台式计算机上的程序服务器或交互式程序,在更短的时间范围内,效率会更高,从而使它们对键盘输入和响应更加敏感。服务更多线程(在应用程序服务器模式下的终端服务上有数千个线程)。

... ...

The situation become more complex when you enable the Foreground Applications option. 启用“前景应用程序”选项时,情况变得更加复杂。 This introduces the "variable quantum" concept. 这引入了“可变量子”概念。 In this case, background tasks receive a different quantum than the quantums received by the foreground tasks. 在这种情况下,后台任务接收的量子与前台任务接收的量子不同。 Also, both sets of quantums are shorter than a thread would receive on a computer set for background services. 同样,两组量子都比线程在计算机组上为后台服务接收的线程短。 Currently, a background process receives a quantum of 3 and a foreground process receives a quantum of 9. Therefore, you can calculate the length of time the thread will run before its timer expires. 当前,后台进程的量子数为3,前台进程的量子数为9。因此,您可以计算线程在其计时器到期之前将运行的时间长度。

Read the whole link for more details. 阅读整个链接以获取更多详细信息。 TL/DR: background services receive longer quantas. TL / DR:后台服务获得更长的数量。

However, I highly doubt you need to worry about this setting. 但是,我非常怀疑您是否需要担心此设置。 First and foremost 99.9999% of applications do nothing all the time, but wait for some IO to complete (disk, network). 首先,最重要的是99.9999%的应用程序始终不执行任何操作,而是等待某些IO(磁盘,网络)完成。 Unless you perform arithmetic in a tight loop, your code is, for all practical reasons, never running and always waiting. 除非您在紧凑的循环中执行算术运算,否则出于所有实际原因,您的代码永远不会运行且始终在等待。 A boost helps you nothing. 提升对您无济于事。 And I highly doubt you really need to deploy a service that does high CPU in a tight loop. 而且,我非常怀疑您是否真的需要部署在紧密循环中具有较高CPU性能的服务

A much more relevant topic for you would be to go over the High Performance Windows Programs to learn how to write proper performance programs on Windows (ie. use IO queue completion status and friends). 与您更相关的主题是浏览“ 高性能Windows程序”,以学习如何在Windows上编写适当的性能程序(即,使用IO队列完成状态和好友)。

And, if you need a CPU boost, just disable CPU power savings in BIOS . 而且,如果您需要CPU加速,只需在BIOS中禁用CPU节能功能即可

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

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