OLD ARTICLE (still better than all those that tell you to edit the registry)
A month ago I wrote a long blog post about CPU Parking, a new feature of Windows 7 / 2008 R2. Since I later deferred release of a quick feature to toggle this system setting, I deleted the rambling blog post. I decided it was past time to restore some information on CPU Parking.
CPU Parking is a feature of multi-core/SMP systems that disables cores when the system load is low enough to allow such. Windows provided no direct way to adjust this via the user interface, as they likely thought everyone would want to keep this enabled. According to public documentation on the feature, unpark time is near instantaneous. Indeed, it may very well be. Additionally, by parking CPUs you can potentially reduce core thrashing - when a thread is swapped between cores unnecessarily, causing a performance hit.
However, for systems where power consumption and heat are not an issue, but maximum performance is, it may be desirable to disable CPU Parking. The fact is that even if unparking is near instantaneous, CPU utilization usually occurs in very brief bursts, something I mention frequently. If you look at your CPU utilization and see 15%, that is actually the percentage of time the CPU was active within a relatively large interval (usually 1 second). Actual CPU utilization most often occurs in micro-bursts where the CPU is fully consumed for a few nanoseconds or microseconds. You want those bursts to execute as fast as possible, and this is why all power saving technologies, including frequency scaling, incur *some* performance hit. This is also why a faster CPU does matter, even if you typically don't utilize 100% of available CPU time over a larger interval.
Whether or not Core Parking is actually used on your PC depends on a few factors. First, your PC must be have at least 2 physical or logical cores/CPUs. Most of the time it is enabled for laptops and servers, but not for desktops. It can also vary between vendors, as many create sets of custom power schemes supposed to offer better performance or improved battery life (rarely do they). It also can vary between Windows editions. The Server Editions tend to make more aggressive use of it by default.
Want to see if it is active or not? Fire up the Windows Resource Monitor and go to the CPU tab. Parked cores will be clearly shown as 'Parked' in the caption of their graph. CPU Parking is actually done quite aggressively. On a dual-core HyperThreaded Core i5 (4 logical cores), I have seen cores parked even as total CPU utilization approaches 50%. Windows seems fairly smart, parking the HyperThreaded/fake cores first.
Changing CPU Parking Settings
Many places on the internet tell you to edit the registry directly when adjusting CPU Parking. I don't actually recommend this. Instead, use the console mode powercfg.exe. Using it you can also tune the CPU Parking so that a certain percentage of your cores must remain unparked at any given time.
You must run this utility with elevated rights, so be sure to open an elevated console window by right-clicking 'cmd.exe' and selecting 'Run as Administrator'.
To mandate 50% of available cores always remain unparked, run:
powercfg -setacvalueindex scheme_current sub_processor bc5038f7-23e0-4960-96da-33abaf5935ec 50To adjust it so that only 25% of available cores remain active at all times, allowing 75% of available cores to be parked, you'd run:
powercfg -setacvalueindex scheme_current sub_processor bc5038f7-23e0-4960-96da-33abaf5935ec 25
Yes, you can use '0' - Windows is not stupid enough to park all cores at once, it will always leave at least one core active. In fact, this is usually the default setting when it is enabled. For example, to enable maximum use of CPU Parking:
powercfg -setacvalueindex scheme_current sub_processor bc5038f7-23e0-4960-96da-33abaf5935ec 0To disable CPU Parking completely, you'd want to run:
powercfg -setacvalueindex scheme_current sub_processor bc5038f7-23e0-4960-96da-33abaf5935ec 100After changing the power scheme settings for CPU Parking as desired, you then want to make the changes active by running the command:
powercfg -setactive scheme_currentWhen I first wrote this I included allowing specification of AC or DC (battery) values for the power scheme. Setting the DC power value isn't documented, so I am going to skip that. Still, to do so you'd simply replace '-setacvalueindex' with '-setdcvalueindex'. It also is not entirely clear if this is supported for every power scheme, though it certainly appears to be. Sadly, Microsoft's documentation is quite scarce.
You should not have to reboot for these changes to take effect. Go ahead and check the Resource Monitor and verify that CPU Parking is indeed as you set it.
I hope this helps some people. Why would you go around making manual edits to the registry when powercfg can do the job for you? You shouldn't. Registry edits are prone to mistakes and are generally more tedious and less clear.
Enjoy ;)
0 comments:
Post a Comment