in reply to Re^4: portable way to get system load average
in thread portable way to get system load average
i need this functionality for throttling purposes. daemons written in perl that sleep in the background based on load. the daemons doing maintanence shouldn't starve the ones making money. i know load is not perfect for this, but it's usable.
The point is, that won't work! By the time your code has obtained an instantaneous cpu load reading, it has changed. And by the time you're code has decided what to do about the out-of-date reading it has, it has changed again.
Have you heard of Hysteresis?
You will either drive your systems into chaotically unstable boom-bust cycles where everything sleeps and then they all wake up together and you get a huge burst of activity; which they all detect and therefore go back to sleep.
Or, you smooth the reading by averaging them together over a few seconds. Then your code is reacting to an approximation of the real situation as it was a few seconds ago. Net result is that anything from 10% to 30% of your cpu is spent accessing, calculating, and deciding whether to sleep or work; and wasting context switches by sleeping when you could be doing useful work.
And whatever calculations you come up with for your breakpoints through trial & error, every time a new process is added, or a new device; or one of either is removed; or you move to a faster cpu; or more cores; or get a faster disk; or the cpu drops the clock rate because one or more cores are overheating; all your calculations go right up the swanny.
Load balancing/throttling processes based upon instantaneous cpu loading doesn't work. It never has, and never will!
Besides which, every modern OS has a very simple, and extremely effective way of ensuring that "money making processes" are favoured over "maintenance processes". The keyword here is PRIORITY.
Look up "nice" if you're on a *nix system; or type help start at a command line prompt if you're on Windows. It can also be done programmically.
saying "you dont need this really" just because perl cannot provide it without extra strap-ons is apologetics at its worst.
I'm certainly not apologising. Perl can provide it quite easily, but other than writing replacements for top/TaskManager, it doesn't have a use. Hence no demand.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: portable way to get system load average
by loadaverage (Novice) on Jul 07, 2010 at 12:42 UTC | |
by BrowserUk (Patriarch) on Jul 07, 2010 at 13:31 UTC | |
by loadaverage (Novice) on Jul 07, 2010 at 14:15 UTC | |
|
Re^6: portable way to get system load average
by JavaFan (Canon) on Jul 07, 2010 at 14:11 UTC | |
by BrowserUk (Patriarch) on Jul 07, 2010 at 14:55 UTC | |
by loadaverage (Novice) on Jul 07, 2010 at 16:13 UTC |