Hani Ayoub
Hani Ayoub

Reputation: 67

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. 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?

Upvotes: 1

Views: 4273

Answers (1)

Remus Rusanu
Remus Rusanu

Reputation: 294307

To answer the question, see Description of Performance Options in Windows:

You can use the performance options to set Windows be optimized for either foreground programs or background services. 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.

...

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.

Read the whole link for more details. TL/DR: background services receive longer quantas.

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). 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.

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).

And, if you need a CPU boost, just disable CPU power savings in BIOS.

Upvotes: 4

Related Questions