Nice Performance Tuning For UNIX
Professor writes "Be 'nice' to your computers and examine some general guidelines for tuning server performance. A computer is like an employee who does tasks for you -- it's a good idea to keep from overburdening them. Keep this from happening by using the UNIX 'nice' command."
Set 'em all to -19, and let the best program win! If they don't have to fight each other for CPU cycles they will grow up weak and feeble.
ad logicam Claiming a proposition is false because it was presented as the conclusion of a fallacious argument.
I guess once you've given nice a shot you could move on to killall -KILL 1. That'll show any misbehaving system who's boss.
nice -19 -n doFirstPost
i'll surely get first post this way!!!
"Facts are meaningless. You could use facts to prove anything that's even remotely true." - Homer Simpson
Performance tuning means that IO and other resources are sufficient to run tasks. The 'nice' command isn't that. 'nice' lets you run jobs whose complete time can vary, since you can put them on the bottom of the list.
/proc, and matching file and FS parameters with your page size.
Performance tuning is fiddling with
This is a non-article.
I want to delete my account but Slashdot doesn't allow it.
When using 'nice' try the -666 option to enable the evil bit. Hilarity will ensue.
Now here's a fun thing to do: rip a DVD with several programs at once, all at nice -19 at you suggest, and encode it to XVid and DivX and Theora all at once for good measure.
Watch the DVD drive churn and seek and gasp!
Watch the encoders fight for CPU time with top open in a terminal window!
Run some unnecessary I/O-bound process like updatedb in the background so that the hard drive can get in on the thrashing!
Wheeee! What fun...
My bicyles
You don't need the nice utility.
Some "R" stickers along the side, a huge wing on top of the box, and replacing the sound card with a fart can is all you need to tune your server.
FTFA: "In fact, only the ps command was running when I generated this list. Most tasks are designed to do what they need to do quickly and then exit or sleep."
/proc/self for a while.
Of course, because all other processes, at the instant PS was running, were blocking on the CPU. In other words, on a uniprocessor system, you can only have one process running at a time, and in the case of a process that reports the state of other processes, its only THAT PROCESS THAT WILL APPEAR RUNNING...
Go play in
-- (appended to the end of comments you post, 120 chars)
Ah, yes, the extremely bad idea of running updatedb at low priority surfaces again. Then, instead of finishing during the early morning hours, it lasts all day, interferring with real work. Yes, this is what really happens: we tried this quite a while ago in Debian, and it's a Bad Idea(tm). What happens, IIRC, is that updatedb gets CPU so rarely that other tasks end up flushing the file buffers, and updatedb has to re-read the disk, over and over.
If the problem is that your system isn't on all the time, and anacron is running updatedb when you log in, then just disable updatedb. You probably never use 'locate' anyway.
Wow! Amazing what constitutes for an article on Slashdot.
"nice" is but a small subset of performance tools, and is the least likely command I would run on a system.
"nice" is fine when you have a series of batch jobs, and you want a specific job to recieve more CPU than another. That's a very small subset of realworld situations.
I agree completely. ... ...
WTF?
My bicyles
Under FreeBSD default shell is csh and it has its own nice command version. So it is better to use full path if you wanna use /usr/bin/nice. Remember your shell deals with different commands and command line options to process your request: /etc/passwd | wc -l) /etc/passwd > /tmp/names)0 06/02/how-linux-or-unix-understand-which.php
1. Internal commands aka shell builtin command (such as set or nice)
2. External commands (such as clear, date)
3. Aliases (such as alias rm='rm -i')
4. Command substitutions ( such as echo "Today is $(date)")
5. Functions
6. Pipes ( such as cat
7. I/O redirection (such as cat
Src: http://www.cyberciti.biz/nixcraft/vivek/blogger/2
Wow, what a lame article. I would go to Digg if I wanted to read crap like this.
I wish we had better support for winmodems in Linux...
[sorry for offtopic]
There are two keys to efficient server tuning. One, build the server with the capability to run at least 3 times as much as you need right now. Then kill -9 any process that slows your watching the p0rn filter go nuts during lunch and breaks. Who really needs a freaking relational database engine anyway? The accounting department can kiss off, you have blackmail to collect.
No animals were harmed in the making of this sig.
Well, there was that one puppy, but he is all better now.
Pun intended.
Which one of you basement runt been treating UNIX so badly that someone had to post an article on being "nice" to UNIX? Someone here deserves a beating with a network cable.
Maybe Gentoo is radically different, but if I recall correctly, "nice" only sets processing priority, as opposed to overall burden. You could have 20 processes running, or 1, and regardless of their 'nice' setting, either could take up to a maximum of 100% processing power available. Computers are built to take this sort of abuse, that's why we have fans and heat-sinks. Just don't overclock if you're that worried. 'nice' only determines which process will have first dibs on that processing power. Basically, you will have the CPU running at 100% until the remaining processes require a total less than 100%. It is only useful for processes you wish to complete ASAP, or for something you can put on the back burner until there isn't anything more important to crunch. This truly is a non-article.
"Bad times have a scientific value. These are occasions a good learner would not miss." ~ Ralph Waldo Emerson
I used to work at NASA/GSFC, and one of the workstations there sat all day running periodic housekeeping tasks from cron -- parsing telemetry, handling command load updates, etc. The problem was that every once in a while something would stall and the next batch of cron jobs would launch before the first ones completed. Instant snowballing death would ensue as nothing completed and the load average would soar into the hundreds as cron maniacally, stupidly spawned more and more processes into the poor overloaded workstation.
There are several relevant tools available now but then I wrote my own - a perl script called "qproc" that would queue up jobs for execution, kill them if they hung too long, and refrain from launching multiple copies of the same job at the same time.
Until I got hit by that, I never thought about the fact that cron is very dangerous to use on a production server. But it is -- if cron tasks use a non-infinitesimal part of the computer, you have to take steps to prevent the same marching-broomsticks failure mode.
nice and not running updatedb... woooooo
Yep. We had that problem as well with some big file servers and NFS. It turned out that pdflush was set to flush data to disk once every five seconds if filled, and once every 30 seconds if stale. This was KILLING our NFS performance. Of course, once we found the real performance tuning points in /proc/sys/vm, we were home free on that. Using nice as a performance tuner of a system is just silly. nice can be used to tune the performance of programs interacting with each other to some extent, but when it comes to the system as a whole, it is a relatively small subset of the whole she-bang.
Is the news so slow today that Slashdot thinks it OK to post articles better left on techincal-how-to websites? Give me a break...
www.TakeArms.com
man woman
Or for that matter:
'How would you rate the dishonesty of Prez Bush?
The CB App. What's your 20?
Looks like I left the average /. crowd (including the editors) far, FAR behind myself in terms of nerdiness.
Those painful FUD and buzzword overloads in some articles were already suspicious. But now I'm vertain of it!
Can someone suggest a site like slashdot for more advanced nerds?
Please, for the love of all that's holy and Unixy, teach yourselves what a SIGCHLD is and how to use wait(2).
In the course of every project, it will become necessary to shoot the scientists and begin production.
I use it on my own system all the time. I've got a dual processor Mac, but once in a while I have too many things running in the background (encoding a movie, analyzing my data in Matlab, etc) and want to keep manipulating some images in the foreground, so I set Quicktime and Matlab and whatever else to -19 priority. They still finish, but when I need the processor to open/close/resize/apply a filter to my image, it takes it and then lets the rest work on the past stuff. I find that it can greatly increase the amount I get done in a day and makes my Mac feel as fast as it is when I'm not doing anything else.
I also tend to increase the priority on httpd processes on the same Mac since I host my website from it. It doesn't take much CPU time, but when a request comes in, I want it to respond as quickly as possible, so if I'm doing a lot, it will give priority to it.
Also, Boinc (the grid client for distributed computing) always sets all the jobs to -19 when they are run. I barely even notice if they are running in the background.
Does anyone know why lower numbers give higher priority? Isn't it more intuitive to use higher numbers for higher priority? I'm curious as to why it was done this way...
Is Ric Romero taking notes on this article?
I can't remember which version it was, but I once saw a manpage for nice that said:
BUGS
Nobody ever uses this command.
Now I find there's also a ls command for listing files and directories? Even a chmod for changing permissions! Who knows what's next. You know what would be really cool - that would be like... multitasking and multiuser features. Yeah. That would be TOO rad. :)
I run nice on all my programs because I'm just not as important as everyone else.
nice article.
fak3r.com
Er? do you mean +19? The lower the number the higher the priority.
Qouth:
-n priority
Specifies how the system scheduling priority of the executed utility is
adjusted. The priority argument is a positive or negative decimal
integer.
Positive priority values cause a lower or unchanged system scheduling
priority.
Negative priority values might require appropriate privileges and cause
a higher or unchanged system scheduling priority.
So, stuff in the background would be 19...
The only use for nice I've ever been forced to implement was renicing processes based on the job submitter's rank in the company. (This was a CPU-intensive render/simulation farm.)
Well, there was time some bozo's log rotation script filled up var with log copies - he copied every file every day, even copies of copies, until the filesystem ran out of inodes. THere were too many files to delete with "rm *", so I did something like "for n in 0 1 2 3 4 5 6 7 8 9 ; do nice -n $n rm ${n}*; done". I don't think it made one bit of difference, the buffer cache is still mad at me.
Give a man a fish and you have fed him for today. Teach a man to fish, and he'll say "WHERE'S MY FISH, YOU IDIOT?"
Thirty of nice and now this groundbreaking article. What's next in the series? Using ps to manage processes??
WTF?
Anyone know the historic reason why negative numbers are used for processes with HIGHER priority? It's counterintuitive and everything that's not *nix-like does it differently.
Gamingmuseum.com: Give your 3D accelerator a rest.
They are my slaves.
I will thrash them if they don't do what I want. Eventually they will die from overwork, or be shot in the head for being too old to run modern programs.
I think you're off by a factor of -1.
Negative numbers (down to -19) have the highest priority, and positive numbers have the lowest priority. Yes, it's backwards and nonsensical and I can only assume that some programmer somewhere is having a good laugh at everyone who's ever been confused by it.
I personally haven't ever used "nice" on my Mac -- most of the stuff I launch from the commandline isn't that processor-intensive. I do use "renice" a lot, which modifies the priority of a process that's already running. So I think that would be what you'd use, if you wanted to bump Handbrake or something to a lower priority. (Not that I know from personal experience what Handbrake is, or does, or anything, *cough*)
I'm not sure if "renice" comes with OS X by default or whether I had to install it at some point.
"Ladies and gentlemen, my killbot features Lotus Notes and a machine gun. It is the finest available."
Have you ever finished first in life? First in line is next to go.
You see? You see? Your stupid minds! Stupid! Stupid!
unzip ; strip ; touch ; grep ; finger ; mount ; fsck ; more ; yes ; umount ; sleep
To run a program in hog mode, you would go 'nice --19 runmenow'
Thus, his '-19' reference makes complete sense.
-- at least that's how it works for the 'nice' binary, and bash. csh, on the other hand, uses 'nice +19' to be nice and 'nice -19' (as root) to be nasty. -- One of the many things that csh does weird that weaned me off of it. (but let's walk away from bash/csh flame wars, shall we?)
OS Software is like love: The best way to make it grow is to give it away.
A computer is like an employee who does tasks for you -- it's a good idea to keep from overburdening them.
Don't I already pay this hunk of junk enough in electricity and bandwidth to keep it from slacking off? If it isn't willing to constantly pull more weight, for the greater success, what am I keeping it on for?
Terrorists can attack freedom, but only Congress can destroy it.
A good [Linux] scheduler already does process restart immediately upon unblocking to reduce latency.
But an overloaded box is still overloaded. The question is how you want it to fail. In what direction? A little cron job watching load with a shedding/restart list probably does better.
For Mac OS X users trying out the commands in the article, you need to type the following to get the list of processes as shown in the article:
ps -ax -o pid,state,nice,command | less -5Also, on a standard Mac OS X system, the updatedb command to update the locate database is run by cron from the 500.weekly script located in /etc/periodic/weekly/.
The future is in beta
I always thought the command was "nice" because lowering the execution priority of noncritical tasks was the "nice" thing to do -- for the other processes on a single user system, or for the other users on a multi-user system. If this is a true, a nicer process runs at a larger integer, where a jackass process runs at small (i.e. large and negative) integer.
I guess I have a lot to learn!
Educating people about their systems isn't a bad thing, but ought this really be front page news on Slashdot?
Its also very helpful to run Apache at nice level 5. That way when the CGI programs go nuts and the load shoots up to 200 the sshd process won't get starved for CPU time and you can still log in to fix the server.
Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion.
Still works with GNU tools (I did say above 'no text'. Damned /. anti-lameness filter).
Tested OpenSuSE 10.0, debian sarge.
This IBM guy not only RTFM but he Wrote An Article About TFM.
You do know about "powernowd -n", don't you?
Definitely! Prioritizing local hard disk access according to process nice levels shouldn't even be all that hard to implement and quite useful.
Doing the same thing to network traffic is another matter, because the network has to support that in some fashion.
What would really be 'nice' would be a way to set relative SCHED_OTHER thread priorities on Linux...
Or even better a way to run threads in different security contexts in the same process, with memory protection, visibility control, and so on. The POSIX standards in this area are a real drag...
You don't have this problem if you run the program correctly, e.g:
nice -n 19
nice -n -20
From the info page:
On older systems, `nice' supports an obsolete option
`-ADJUSTMENT'. POSIX 1003.1-2001 (*note Standards conformance::)
does not allow this; use `-n ADJUSTMENT' instead.
Use nice(1) and renice(8) to performance-tune your server ... DUH!
... this is not even sysadmin 101-level material ...
C'mon IBM
Here I was all ready to receive the latest recommendations from Big Blue about WHICH processes should be set to WHICH nice(1) level to make a decent first approximation of a well-balanced server and all I get is this stuff.
Very disappointing.
utter rubbish
Yes, you are right on both accounts - I wasn't thinking when I typed it and got the negative siign and I use renice. I actually type: "renice 19 process_id" to make it more nice (positive number). Negative numbers are less nice.
It does come with "OS X" by default.
Not quite: the load average also takes into account processes in uninterruptible sleep states (i.e. waiting for disk i/o).
While we're on the subject, I found this interesting: the load average isn't your average average.
Some facts are wrong, or Linux specific where described as Unix-generic (for example, other Unixes have varying priority levels). Most of this is trivial to system administratiors, yet there is unneccessary detail for beginners. Too unfocused to be useful to any audience.
ratings:
Helpful: no (x)
Useful: [1] not at all (x)
This, like quite a lot of IBM devnet articles, seems to be produced for page count, not usefulnes.
The basic UNIX scheduler has been broken since 1971. If you want something that's "nice" then learn how to use the fair share scheduler in Solaris!
As far as I know the latter is a Unix deritive, not a full Unix setup. And when I look at Unix I think Sun's DTrace approach on Solaris (being ported to *BSD) simply kicks the ancestors ass big time.
This only increases the risk of bad *nix administration. A program doesn't perform as well as it should, you raise priority and watch it affect the rest of the machine. In the end you'll end up buying other hardware or perhaps doing other symptom fighting while you could have removed the culprit itself.
I remember I once baked a PII 333 by running the setiathome number cruncher in three instances and then nicing them to -19.. it took about three hours before the chip ceased to function.
-if at first you don't succeed, stay the heck away from paragliding.