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

  • 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...
  • Process Lasso v3.65.3 beta released
    I've released the first new beta that is 100% UNICODE. I've regression tested almost all the software, though there may still be som...
  • 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...
  • v5.0.0.18: Fix auto updater in XP
    During testing a few hours ago I noticed the auto-update was failing in some XP installations. Specifically, it would appear to stall at the...
  • BETA: Vista startup configuration
    Ok, I've got this fully correct now I think. In some cases in previous builds you could end up with both registry and Task Scheduler sta...
  • 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...
  • v5.0.0.17 final - Minor fixes
    This build fixes a reported issue with the watchdog rules (re: not default affinities, priorities, power schemes, but rather the terminate/r...
  • v5.0.0.21: Fix failure of web links within Process Lasso on some systems
    I've had reports of sporadic failure of the web links within Process Lasso. I've analyzed this situation for a while today and found...
  • One bit of bad news, one bit of good news
    One disappointing thing is that I've decided to cancel the change history shown in the update dialog, at least for v4.1. I may add it in...
  • Oh the frustration with this corporate crapware!!
    I now get uninstall feedback, as I solicit it (for better or worse). Once read, I can never go back, lol. Fortunately, most of it is actuall...

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