I had used Autonice on various Osf/Digital Unix/Tru64 Unix boxes over the years, and needed something similar for Linux in a hurry. Hence I tried to port autonice so that I only had one such type of software to document as being in use on the servers…..
What is Autonice
From the original README file:
This is autonice, a program to automatically lower the priority level of long lived processes for DEC OSF/1 AXP. The latest version of the software used to be obtained from: (this seems dead now…)
The principal aim of the program is to give short lived interactive processes more CPU time than long lived batch style jobs. The idea behind this is that those long lived jobs might take a little longer to complete, but if a process is going to run for 24 hours anyway then it does not matter too much if it takes an extra 30 minutes.
The nice level is set according to the following function:
nice = 4 * (int)(log(cputime / 60.0) / log(2.0))
Thus after two minutes of CPU time the process is set to nice 4 and after 32 minutes of CPU time it is set to the minimum priority level of nice 19.
Originally by Ray P. Bellis (MRC Center in Brain and Behaviour, Dept of Experimental Psychology University of Oxford), and latter extended and currently maintained by Massimo Ianigro it has long been a useful way to lower the priority of long lived jobs on Alpha machines under OSF/Dunix/Tru64 Unix.
In 1999 I ported it to Linux since my group has a nice mix of alphas and Linux boxen and I wanted my programmers to see the same behaviour on all of the computers.
The Linux port
Autonice reads /proc to findout what is going on. So the main thing was to set it up to read a Linux style proc. It was not very hard to do.
At present the code is still hackish awaiting me to find the time to rewrite it. It is about half way towards being able to simple retarget the code that reads /proc and then it should be portable to any /proc based un*x like OS. YMMV.
Users who submit multiple jobs. The code treats each job from each user equally. This was fine when all users were treated the same, but when Massimo added support for treating individual users differently, problems cropped up.
for example if user A is set to nice 4 always, and user B to nice 10 always things are fine if they each have equal numbers of jobs. But if User B starts 3 jobs, then each user B job is treated the same and so user B gets much more CPU than user A.
Basically autonice is very simple. BUT these sorts of problems need more care. And were not what Autonice is designed for. If you have a more complex environment, then you really want to look at Pset or something else.
Usual disclaimers (ie it is all your fault. If you do not look at the source of this daemon, and if you do not understand it, that is your problem. In any case I make no warranties for this code.)
Wed 6 April 2005
This release fixes a bug reading the config file, and in collecting all of the process and its children’s cpu time.
- Autonice – confusingly a Perl based program of the same name. This one has no relationship with the Autonice on this page.