Nice Performance Tuning For UNIX 206
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."
Scheduling Priority is for sissys (Score:5, Funny)
Have a DVD-ripping death match! (Score:5, Funny)
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...
Re:Have a DVD-ripping death match! (Score:3, Funny)
Re:Have a DVD-ripping death match! (Score:2)
Re:Have a DVD-ripping death match! (Score:3, Interesting)
In the first case, a large simple parsing app or file compression/decompression can saturate an IO bus. While performing such operations, other user-sensitive tasks like opening an application or checking mail. Granted most users don't do a lot of IO-flooding apps, but what's more prevalent are network-flo
Re:Have a DVD-ripping death match! (Score:3, Informative)
With network bandwidth it's quite application-specific. For example I can tell Azureus (uber-featureful bittorrent client) to only use a certain amount of upload bandwidth. But I can't do this with Gaim, and when I'm sending someone a big file too fast, my web browsing grinds to a halt. It'd be handy to have a uniform way to restrict the bandwidth of apps.
Storage device accesses would be a
Re:Have a DVD-ripping death match! (Score:2)
you should be able to throttle by port, user account and a whole manner of other things.
Re:Have a DVD-ripping death match! (Score:2)
Now I wonder if without using virtualization, on the command line, you could limit memory available to a process. One of the big 3 UNIXen out there probably has that.
Re:Have a DVD-ripping death match! (Score:2)
And didn't your DVD drive thrash around horribly while you had three programs trying to read
Obviously, you're doing this much smarter than I did
Re:Have a DVD-ripping death match! (Score:2)
Re:Scheduling Priority is for sissys (Score:3, Interesting)
Re:Scheduling Priority is for sissys (Score:2)
is there a similar option for kernel modules ? some kind of scheduling trick ? the vmplayer from vmware is quite nice, but with it's kernel module it totally annihilates the rest of your linux, and renice'ing the vmware's process itself doesn't really have an effect, since the kernel module is wh
Re:Scheduling Priority is for sissys (Score:2)
Re:Scheduling Priority is for sissys (Score:2)
Re:Scheduling Priority is for sissys (Score:2)
Once, while in college, I was sitting in the Solaris lab wondering why every workstation was slow as molasses. It quickly became apparent that an over-enthusiastic EE major was using every workstation in a cluster to do his bidding. He was not being 'nice' at all
Re:Scheduling Priority is for sissys (Score:3, Insightful)
Very funny. Its like when I'm talking to people that believe in heaven and hell, I just say "Kill 'em all and let God sort them out!"
But back on the topic. Err, I'm new to UNIX/Linux, I've only been using it since 1993, but nice and getpriority() setpriority() and scheduling have been around for a _long_ time.
Debian launches services via the start-stop-daemon program th
Re:Scheduling Priority is for sissys (Score:2)
Re:Scheduling Priority is for sissys (Score:2)
I don't mind refresher stuff either, but UNIX was designed from the beginning to be multi-user and multi-tasking. The top command has a nice column. The manpage for top says:
The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task's dispatchability.
nice, and renice are common commands for dealing with running processes. top can renice a process as w
Re:Scheduling Priority is for sissys (Score:2)
Considering that half of the
Re:Scheduling Priority is for sissys (Score:2)
Considering that half of the
I consider myself pretty "new" to the UNIX/Linux world, too, and I've been using some variation since 1993. I'll stop considering myself new when I can remember every command
Re:Scheduling Priority is for sissys (Score:2)
By that standard everyone is a *nix newbie.
Re:Scheduling Priority is for sissys (Score:2, Insightful)
While we are on the topic, is there a market for a slashdot style site that is more geared for computer professionals?
Slashdot has a very smart userbase, and I would not abandon slashdot, but I would like to get away from the highschool and undergrad "know it all" people. Articles like this one are way below anyone who does Linux or
Re:Scheduling Priority is for sissys (Score:3, Informative)
Slashdot has a *lot* more users than either though. Although some times it can seem otherwise, the good comments can show though... you just need to browse at +4 and ignore anything posted = 25 minutes after a story is posted.
Re:Scheduling Priority is for sissys (Score:3)
Hey, I browse at +4 already. 90% of my foes are those MMLM people with "free" iPods in their sigs. That has gotten rid of most of the college kids. I'm a subscriber and give bonus points to friends, friend of friends, interesting, informative, yada yada. I've been reading slashd
Re:Scheduling Priority is for sissys (Score:2)
Have all of the apps be aware of their nice levels, and strive to bring their nice levels up. However, they can't adjust their own nice levels, but they can adjust other apps nice levels....
Put in other limitations as well, so it doesn't just throw everything out the window. As in, the top niced program can't be reniced until it's not the top niced program anymore... and every time you nice an app, another app at random automatically loses niceness..
Would be i
First Post? (Score:5, Funny)
i'll surely get first post this way!!!
Next up: "man nice" "man man" "man mount" ? (Score:5, Insightful)
Performance tuning is fiddling with
This is a non-article.
Re:Next up: "man nice" "man man" "man mount" ? (Score:5, Funny)
Re:Next up: "man nice" "man man" "man mount" ? (Score:5, Funny)
Re:Next up: "man nice" "man man" "man mount" ? (Score:2)
Well, the lazy bastard who programmed it didn't check for arguments "am" and "i", but just checked to see if the argument count was 2, all other valid arguments being single items.
So it was sometimes amusing
Re:Next up: "man nice" "man man" "man mount" ? (Score:2, Funny)
gawk; talk; nice; date; wine; grep; touch; unzip; strip; touch; gasp; finger; gasp; mount; fsck; more; yes; gasp; umount; make clean; make mrproper; sleep
Re:Next up: "man nice" "man man" "man mount" ? (Score:5, Insightful)
So I'm always suspicious when I see nice used. I really prefer to just schedule more intelligently, so things don't overlap as much, and running daemons that hog cycles 24/7 on their own hardware.
Re:Next up: "man nice" "man man" "man mount" ? (Score:3, Insightful)
Well, this joker has root access, because only root can increase a priority of a process.
No system I run with multiple users would have such an incompetent person that is allowed to have root access. In fact, when a user writes some broken perl script that burn
Re:Next up: "man nice" "man man" "man mount" ? (Score:2)
Re:Next up: "man nice" "man man" "man mount" ? (Score:2)
Tanks! Now I'll need to do all that calculation again...
Re:Next up: "man nice" "man man" "man mount" ? (Score:2)
You must be one of my users
No, you need to fix the application because if its burning up the filesystem and CPU unnecessarily, I will kill the process until its fixed.
Running a calculation is not something you do on a multi-user system. I can point you to 500+ dedicated processors for that. A simple perl script that is running as a daemon that is written so poorly that it opens and closes files without reading any data from them in an endless or a
Re:Next up: "man nice" "man man" "man mount" ? (Score:2)
nice is great for running long jobs in background (Score:2, Insightful)
Re:nice is great for running long jobs in backgrou (Score:2)
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 run
Re:nice is great for running long jobs in backgrou (Score:2)
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?)
Re:Next up: "man nice" "man man" "man mount" ? (Score:3, Informative)
Re:Next up: "man nice" "man man" "man mount" ? (Score:2)
Re:Next up: "man nice" "man man" "man mount" ? (Score:2)
Having said that, I do nice down my "top" processes and set the delay to at least 5 seconds. This seems to give a better idea of what's running a lot as top then uses less resources.
$0.02USD,
-l
Here's a tip. (Score:5, Funny)
Re:Here's a tip. (Score:2, Funny)
Re:Here's a tip. (Score:2)
I got my server tuned (Score:2, Funny)
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.
Re:I got my server tuned (Score:2)
Bad teacher, no cookie! (Score:5, Insightful)
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
Re:Bad teacher, no cookie! (Score:2)
Re:Bad teacher, no cookie! (Score:5, Insightful)
Nota : I put the GNU because BSD equivalent behaves differently, I just checked and I get details like "select" where I guess I would only get "Sleep" on GNU/Linux.
Re:Bad teacher, no cookie! (Score:4, Insightful)
Not true. "Running" as a process status doesn't mean that the process is burning CPU time right now, it means that it is in the runqueue and will round-robin with all the other running processes for the CPU time.
The opposite state, sleeping, means that the process is not currently in the runqueue because it is waiting for something - for a disk read to conclude, for some data from the network, for your keypress, or simply that some time has elapsed.
I repeat: a "running" process is one that is in the runqueue, not neccessarily being run by the CPU at this particular microsecond.
Re:Bad teacher, no cookie! (Score:2)
He cou
Worst. Advice. Ever. (Score:4, Informative)
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.
Re:Silly question..... (Score:2)
Re:Worst. Advice. Ever. (Score:4, Informative)
In short : nice doesn't change the total amount of time your processes take (or, at least, not by very much), it just changes which one finishes first.
Re:Worst. Advice. Ever. (Score:3, Informative)
No. In the instant case, the problem was that the system was 'thrashing'. Useful data was being flushed, and it had to be reloaded from disk again and again. That causes the system to chew up extra resources and slows things down. In a case like that, increasing the priority of updatedb would have it get it's work done quickly during low priority times and then get out of the way. (of course, if you're on a server, you probably
Re:Worst. Advice. Ever. (Score:3, Insightful)
Actually it does change the total amount of time. The issue in question here is about disk caching. The problem was that, if you run updatedb niced, then it doesn't get to run as often. In fact, it can run so infrequently that between one timeslice and the next, the disk cache has been replaced by other stuff, because of all the processes that ran in between
Re:Worst. Advice. Ever. (Score:2)
One of the funniest things I ever saw as a sysadmin was updatedb running down an arch repository... on a database server.
Re:Worst. Advice. Ever. (Score:2)
I'm genuinely asking. I have no idea. But do you really need to use locate when you can use beagle-query? [antezeta.com]
Re:Worst. Advice. Ever. (Score:2)
For me, I don't like slocate/locate, because I leave my system powered down (suspend/standby), and I'd rather not have updatedb grinding on the hard disk when I bring the system up. It makes my games stutter.
For whatever reason, beagled doesn't grind on the drive as badly as updatedb. It certainly doesn't affect my gaming. I'm sure the memory requirements are horrific, though.
Re:Worst. Advice. Ever. (Score:2)
Beagle is also run per-user, and requires per-user configuration (albeit minimal).
Re:Worst. Advice. Ever. TRY NOATIME (Score:2)
"nice" as a performance tool? (Score:2)
"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.
Re:"nice" as a performance tool? (Score:2)
Re:"nice" as a performance tool? (Score:2)
I agree.
I mean, I know they say you shouldn't gripe about these things, but so many unix(-alike) users don't know the full power of programs like true and yes.
What if I was learning shell scripting and didn't know how to define the truth condition? What would I do? What would you do?? What would Brian Boitano do???
nice good, kill better (Score:2)
Re:nice good, kill better (Score:2)
Heh, on Windows we have three keys for that: + +
Re:nice good, kill better (Score:2)
It killed the joke: I meant ctrl + alt + del
Whatever...
Re:nice good, kill better (Score:2)
What do you store your porn in if it isn't a RDBMS? I need categorization damnit!
Interesting article... even for slashdot... (Score:2)
Repetitive tasks and tuning... (Score:5, Interesting)
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.
Re:Repetitive tasks and tuning... (Score:2)
Algorithm:
- try to get the 'run' lock. if we get the run lock, then run t
Off topic: Zombies (Score:4, Interesting)
Please, for the love of all that's holy and Unixy, teach yourselves what a SIGCHLD is and how to use wait(2).
Low numbers == High priority??? (Score:2, Interesting)
Re:Low numbers == High priority??? (Score:2)
I'm number 1! (Score:2)
Re:Low numbers == High priority??? (Score:3, Informative)
It's confusing if you are used to thinking in terms of priority, but it makes sense after the first few times you see it.
Re:Low numbers == High priority??? (Score:2)
priority / nice = amount of CPU time.
Re:Low numbers == High priority??? (Score:2)
Ric Romero? (Score:2, Funny)
Obligitory... (Score:2)
The only use for nice (Score:2)
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
Jesus, what kind of a commie pinko are you? (Score:3, Funny)
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?
Nice is Nasty (Score:4, Interesting)
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.
nice for the Mac geeks (Score:4, Informative)
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/.
nice -5 apachectl start (Score:3, Interesting)
Re:what about killall (Score:5, Informative)
Yep
In arch/i386/kernel/signal.c [2.6.17-rc1-mm2]
Re:what about killall (Score:2)
Re:what about killall (Score:5, Informative)
The Sun Solaris "killall" command kills *all* processes.
AIX "killall" kills all processes (except those in its family tree) owned by the calling user (maybe owned by the calling user *and* attached to the current terminal...).
Re:what about killall (Score:2)
What exactly the purpose of Sun's killall? I'm sure it's useful to someone, but from here I have no idea why anyone would want to use it...?
Re:what about killall (Score:2)
but yeah, it's probably not something joe user would want to use (the man page says only super-users can use it, but it's set mode 755
Re:what about killall (Score:2)
Re:what about killall (Score:2)
Yep. Found that out the hard way. killall httpd on Solaris does not do quite what you think.
Stupid lame Sun. Why can't they stick to the right way of doing things. Linux has been around for much longer than them, so they should damn well stick to the standards.*
* Please don't feed me.
Re:what about killall (Score:2)
On a related note, I installed Ubuntu yesterday, and I wanted to use it as a headless box, so I monkeyed with
After monkeying with it, I did the standard telinit q to make init reread its config file. Well, telinit q told init to just kill all running processes. Nice feature.
Ubuntu might be OK for a novice who wants to say that they run Linux, but it is not a distro geared for professional use.
Re:what about killall (Score:2)
Long answer: I'm on Debian, so I'm not 100% sure if Ubuntu uses the same sysvinit package, but, I did check it out and 'telinit q' and its manpage both agree on rereading inittab. So, I'd look into filing a bug.
-l
Re:slmodem (Score:2)
How much does a good old-fashioned external serial-port modem cost these days?
Mine was about 20 quid, IIRC. I remember just pointing kppp at /dev/ttyS0 and I was away. None of this hassle.
Re:Negative numbers for higher priority? (Score:2)
Re:Negative numbers for higher priority? (Score:2, Interesting)
So, now with that out of the way, let's say you want to iterate all numbers. Most sane people would start at either the beginning(low value) or the end(high value). And probably most would start at the beginning.
When walking the list of things to run, a simple scheduler would act on the first thing it finds. This means that something that existed lower in this list would be run mor
Re:Negative numbers for higher priority? (Score:3, Informative)
Nice values measure how nice your programs are. Being nice means it gets out of the way for other programs. So a program with a nice value of 10 is nicer than that with a nice value of 0 and will get out of the way.
We could do it the other way around and have a 'mean' program that assigns 'mean' values to programs which then hog th