Home > Enterprise >  Effects of programmatically enabling `Efficiency Mode` for services in Windows 11?
Effects of programmatically enabling `Efficiency Mode` for services in Windows 11?

Time:01-10

Suppose there's a service that's extremely busy during the day but generally idle at night.

Currently Task Manager shows off

However, applying the code changes below, Task Manager shows Efficiency mode enabled

on

It achieves this mode by applying these methods

  • First, the Efficiency mode lowers the process priority of background tasks so that Windows does not allocate important resources to these apps.
  • Second, it deploys something called EcoQoS, which is a Quality of Service package that reduces the clock speed for efficient tasks.

To get the Efficiency mode to appear in the Task Manager, at a minimum these two are required (through trial and error):

  1. Set process priority class to IDLE_PRIORITY_CLASS
  2. Throttle CPU power with PROCESS_POWER_THROTTLING_EXECUTION_SPEED

#include <windows.h>

// Sets the process priority to IDLE_PRIORITY_CLASS.
void set_process_priority()
{
    SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
}

// Enables EcoQos to reduce the clock speed.
void enable_ecoqos()
{
    PROCESS_POWER_THROTTLING_STATE PowerThrottling = { 0 };
    PowerThrottling.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;
    PowerThrottling.ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED;
    PowerThrottling.StateMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED;

    SetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, &PowerThrottling, sizeof(PowerThrottling));
}

int main(int argc, char* argv[])
{
    set_process_priority();
    enable_ecoqos();

    // Process is now running in Efficiency mode...

    return 0;
}

Question

Will enabling Efficiency mode cause degraded performance issues during the day when the service is very busy? (Trying to lower the costs of CPU/Memory usage and make it more Green Software friendly).

Are there other efficiency options that could be enabled to improve the overall Efficiency mode?

CodePudding user response:

Because Efficiency Mode reduces the resources allocated to a service and reduces its priority relative to other running services, switching a process to Efficiency Mode would likely reduce its overall performance.

Whether that matters or not depends on many factors. If the service is well-designed, it should still perform adequately, however. The operating system typically defers to services that are in high-demand.

The point of reducing resources is not to achieve performance gains (to those processes having higher priorities); it is to keep the system responsive. It doesn't make much sense for a background process to consume large amounts of resources if it spends most of its time idle.

I once worked in a company that had a server which polled a SQL Server endpoint ten times per second. As you can imagine, this is quite a waste if the server sits idle most of the day and does the bulk of its work at night. I changed the code so that after six seconds of inactivity, it reduced the polling interval to once per second. After another minute of inactivity, it reduced the polling to once per minute. If a poll produced a request for activity, the interval went back up to 10 per second.

This had the effect of eliminating most of the wasteful activity, while still making the server responsive during its busy times.

  • Related