Slashdot Mirror


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."

10 of 206 comments (clear)

  1. Next up: "man nice" "man man" "man mount" ? by Gothmolly · · Score: 4, Insightful

    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.

    Performance tuning is fiddling with /proc, and matching file and FS parameters with your page size.

    This is a non-article.

    --
    I want to delete my account but Slashdot doesn't allow it.
    1. Re:Next up: "man nice" "man man" "man mount" ? by SatanicPuppy · · Score: 4, Insightful

      One of the things I don't like about nice is that people often use it to baby weak code. Some joker writes the world most inefficient Perl script, and then, because it takes forever to run, uses nice to give it a higher priority than it deserves, thus cutting it's runtime down to an acceptable time, rather than just fixing the damn code. I hardly ever see anyone use it nicely (har har), setting a non-critical job to run at a lower priority.

      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.

      --
      ad logicam Claiming a proposition is false because it was presented as the conclusion of a fallacious argument.
    2. Re:Next up: "man nice" "man man" "man mount" ? by hackstraw · · Score: 2, Insightful

      Some joker writes the world most inefficient Perl script, and then, because it takes forever to run, uses nice to give it a higher priority than it deserves, thus cutting it's runtime down to an acceptable time, rather than just fixing the damn code.

      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 burns a processor for days, I do a trace on the procesws to see what it is doing, kill the process and email the user to fix the code.

      Yes, I'm a BOFH, and proud of it!

  2. Bad teacher, no cookie! by Fubar420 · · Score: 5, Insightful

    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."

    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 /proc/self for a while.

    --
    -- (appended to the end of comments you post, 120 chars)
    1. Re:Bad teacher, no cookie! by alexhs · · Score: 4, Insightful

      Of course, on a uniprocessor system only one task can run at a time. However, (GNU) ps and (GNU) top report R as Running or Ready to Run, so there may be more than one at any time. Average of runnable tasks count get you the load.

      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.

      --
      I have discovered a truly marvelous proof of killer sig, which this margin is too narrow to contain.
    2. Re:Bad teacher, no cookie! by ultranova · · Score: 3, 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...

      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.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

  3. Re:Scheduling Priority is for sissys by hackstraw · · Score: 2, Insightful

    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.

    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 that has the -N|--nicelevel option. RedHat has a function called daemon() in /etc/init.d/functions that takes a nice argument.

    In other words, I'm not impressed with the IBM article or with slashdot for printing this. Oh, and the slocate cron job in most Linux distros has been niced to -19 for years. I guess copying and pasting the contents of the cron script is helpful for people that don't have access to a Linux box. Next week, they are going to HTMLize the kernel source for those that can't download that either.

    I hate being negative here, but what is the target audience for the IBM article and this slashdot reprinting of it?

  4. nice is great for running long jobs in background by Quevar · · Score: 2, Insightful

    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.

  5. Re:Worst. Advice. Ever. by asuffield · · Score: 2, Insightful

    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.

    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 the two.

    The result is that updatedb runs with permanently cold cache. That makes it take hours instead of minutes. Hence the problem. It's not immediately obvious because it only happens when there is a moderate amount of background usage of disk resources - like an active mail server, or a backup job.

    Nice isn't very nice to disk-intensive processes. This feature of unix was designed for cpu-intensive processes. It doesn't work very well on things like updatedb - you tend to get bad interactions like this one. If the system is truly idle then you're safe, but if it isn't then you're screwed.

  6. Re:Scheduling Priority is for sissys by hackstraw · · Score: 2, Insightful

    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 ;)

    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 UNIX professionally, and when I mention things like this the /. moderators slap me with an overrated moderation.

    I'm serious, would there be a target audience of professionals that would like a website geared for them? Does one already exist that I don't know about that has active readers and interactive discussions?