Windows 2000 Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Wednesday, 28 October 2009

Tightening the Governor

Posted on 10:26 by Unknown
Most users of Process Lasso are familiar with its core engine, ProcessGovernor.exe. It is the silent background process that applies all process rules, including ProBalance dynamic priority adjustments. It is implemented as a stand-alone process to allow users to completely close the GUI, further reducing resource consumption and hiding Process Lasso from the user.

This Governor is already highly optimal. Since it has no interaction with the user, it doesn't have to waste memory with pretty icons, and doesn't have to waste CPU cycles refreshing a window. The size of its working set (memory in use) is largely dependent on the number of processes it has discovered on the system. For Windows XP and Windows 2000, it is often 1MB or less. For Windows Vista and Windows 7, its usually close to 2MB.

The number of CPU cycles used is also dependent on the number of processes running on the system, and (most importantly) the refresh rate setting. The refresh rate can be High, Normal, or Low. At High, the Governor acts quickly, but uses double the CPU cycles of the Normal refresh rate. Similarly, a Low refresh rate uses half the CPU cycles of the Normal refresh rate. No matter what, the Governor never uses enough CPU cycles for anyone to really notice. In any configuration, even on the slowest systems, it rarely approaches 0.1% utilization of available CPU cycles in a 1 second interval.

So now we know it uses almost no CPU cycles. That's great, so why bother continuing to work on it? Well, the faster we can get the governor's loop, the quicker it will respond during extreme high load situations.

From now on, when I make new optimizations, I'll write about some of them. I probably won't ever get around to documenting all the important optimizations I've made in the past. So, let's get to it..

For v3.70.2, I've removed occurrences of WaitForSingleObject from the Governor's primary thread. Previously, I was waiting on an 'exit me' event, using the timeout of WaitForSingleObject as the sleep mechanism between iterations.

Additionally, I was also invoking WaitForSingleObject to check if a change notification event was fired for the configuration file. This is, of course, to reload the configuration file when changes are detected.

There's absolutely nothing abnormal or wrong about using WaitForSingleObject (or WaitForMultipleObjects). That API is the mechanism the Windows kernel provides to put a thread to sleep until certain events have fired or a timeout has been reached. It is also the typical way of checking the state of an event object.

However, it turns out that WaitForSingleObject is excessively expensive, inducing an entrance into kernel mode even if there is no contention, and even if its used with a zero timeout to simply check the state of an event object. For a little more insight into the overhead of WaitForSingleObject see this link.

Being so expensive, I decided to remove it from the primary loop of the Governor. First, I switched to a Sleep to pause the primary thread, instead of relying on the timeout of a WaitForSingleObject call. Next, I simply created a new helper thread that does nothing but WaitForMultipleObjects on the events I'm watching (exit and config change). When one gets signaled, I set a global boolean to let the primary thread know the event signalled it next wakes up from its sleep.

Of course, I did have to add a new synchronization object for the code blocks working with the configuration file change boolean. However, that's no problem since a simple critical section with a non-blocking (optional) entrance in the primary thread works great and is highly efficient.

Yep, a simple 2 minute change and a 30 minute article ;p.

The end result is that the primary thread of the Governor no longer invokes WaitForSingleObject. This means no more expensive entrances into the kernel. Now, if only the CPU utilization wasn't already so low that the impact of this change is imperceptible ... ;)
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Process Lasso v5.0.0.28
    This build continues maintenance, fixing several items and also making a nice improvement to the graph's display. Further, the last sele...
  • Tightening the Governor
    Most users of Process Lasso are familiar with its core engine, ProcessGovernor.exe. It is the silent background process that applies all pro...
  • Process Lasso and WDFME
    Since Process Lasso can be complex for the layman, something we are working on, I wanted to list a set of steps to address the commonly abu...
  • Indonesian language added - That makes 11
    Thanks to the work of Ivan Chin, an Indonesian (Bahasa Melayu) translation will be included in v3.99.36. This will be the first time even he...
  • WARNING: Cracks for Process Lasso may modify HOSTS file
    WARNING:  Cracks for Process Lasso have been seen to modify your system HOSTS file so that you can no longer access  bitsum.com  and/or  bit...
  • Optimizing process icon memory use & New core feature coming..
    Two in one post. Yes, here at Bitsum we're going Green by conserving bandwidth ;). Of course, that's just a joke and I fully support...
  • Next update, Options menu gets some changes
    I decided to make the Options menu a little more consistent and move the ProBalnce configuration down with the rest of the rules configurati...
  • Anti-virus software - the #1 cause of PC performance troubles
    Many users realize their anti-virus software consumes massive amounts of system resources, and hope that Process Lasso will somehow keep it ...
  • Process Lasso v5.0.0.48
    Changes: [.48]Change.GUI: Do not show 'Activate Now' menu item after activation [.48]Change.GUI: Adjusted logging thread CPU and I/O...
  • WARNING: Beware of third-party utilities that adjust process priorities (other than Process Lasso)
    Recently I've seen either 'hacked on' additions to existing products, or new products, that have the ability to manipulate proce...

Blog Archive

  • ►  2013 (1)
    • ►  March (1)
  • ►  2012 (6)
    • ►  September (1)
    • ►  July (1)
    • ►  June (2)
    • ►  January (2)
  • ►  2011 (166)
    • ►  December (3)
    • ►  November (2)
    • ►  October (2)
    • ►  September (6)
    • ►  August (12)
    • ►  July (14)
    • ►  June (17)
    • ►  May (19)
    • ►  April (13)
    • ►  March (27)
    • ►  February (31)
    • ►  January (20)
  • ►  2010 (203)
    • ►  December (23)
    • ►  November (34)
    • ►  October (38)
    • ►  September (17)
    • ►  August (19)
    • ►  July (19)
    • ►  June (11)
    • ►  May (16)
    • ►  April (8)
    • ►  March (6)
    • ►  February (6)
    • ►  January (6)
  • ▼  2009 (43)
    • ►  December (6)
    • ►  November (1)
    • ▼  October (10)
      • Process Lasso v3.70.2 released
      • Tightening the Governor
      • Process Lasso v3.70.1 released
      • Process Lasso v3.70 launched
      • ProcessGovernor improvements
      • New final coming soon
      • Is Process Lasso Windows 7 ready? - Yes, it is!
      • Process Lasso v3.65.7 beta released
      • Process Lasso v3.65.3 beta released
      • Two new features and UNICODE
    • ►  September (3)
    • ►  August (1)
    • ►  July (9)
    • ►  June (2)
    • ►  May (3)
    • ►  April (4)
    • ►  March (4)
Powered by Blogger.

About Me

Unknown
View my complete profile