The 'nice' program - getting more time for my program ?

The 'nice' program - getting more time for my program ?

Post by Richard D Holowcz » Sat, 27 Jul 1996 04:00:00



Hi folks. After looking at the man page for the 'nice'
program, I learned that the super-user (root) can specify
a negative priority adjustment to increase the priority of
a job.  So, I did the following:

1) I ran my niftly PERL script as a regular user:
        mybigscript.pl
   Total time to run was 5 minutes 2 seconds
   While it was running, I repeatedly ran: ps -l -u myusername
   and observed the priority (PRI) fluctuated between a low of 49
   and a high of 99.

2) I ran the same script as root with the following:
        nice --adjustment=-20 mybigscript.pl
   Total time to run was 4 minutes 58 seconds
   While running, ps -l -u root showed a steady Priority
   of 40.

So, now for my question - Is nice really doing anything for me ?
I had hoped to get some significant (or at least "noticable :)
speed-up but this was not the case.  mybigscript.pl does a
lot of memory and CPU intensive work (looping through large
arrays and such) and is not disk intensive at all.
Does the priority affect CPU intensive tasks ?  Is there another
way to get more CPU time for my task ?

Specifics:
  Sun Sparc 5 running Solaris 2.5 with Perl version 5.
  No other users on the system in both cases.

Thanks for any pointers.

Rich H.

---

Rutgers University     http://cimic3.rutgers.edu/~holowcza/

 
 
 

The 'nice' program - getting more time for my program ?

Post by janse » Sat, 27 Jul 1996 04:00:00



> Hi folks. After looking at the man page for the 'nice'
> program, I learned that the super-user (root) can specify
> a negative priority adjustment to increase the priority of
> a job.  So, I did the following:

> 1) I ran my niftly PERL script as a regular user:
>         mybigscript.pl
>    Total time to run was 5 minutes 2 seconds
>    While it was running, I repeatedly ran: ps -l -u myusername
>    and observed the priority (PRI) fluctuated between a low of 49
>    and a high of 99.

> 2) I ran the same script as root with the following:
>         nice --adjustment=-20 mybigscript.pl
>    Total time to run was 4 minutes 58 seconds
>    While running, ps -l -u root showed a steady Priority
>    of 40.

> So, now for my question - Is nice really doing anything for me ?
> I had hoped to get some significant (or at least "noticable :)
> speed-up but this was not the case.  mybigscript.pl does a
> lot of memory and CPU intensive work (looping through large
> arrays and such) and is not disk intensive at all.
> Does the priority affect CPU intensive tasks ?  Is there another
> way to get more CPU time for my task ?

> Specifics:
>   Sun Sparc 5 running Solaris 2.5 with Perl version 5.
>   No other users on the system in both cases.

> Thanks for any pointers.

> Rich H.

> ---

> Rutgers University     http://cimic3.rutgers.edu/~holowcza/

Nice is not as easy as it seems. Using nice may have no effect at all or
even have the opposite effect of what you intend. Nice only effects
processes in user mode. Heavy CPU mode as you say is not a criteria.
You should look at the user and system time and read about UNIX
scheduling meachnism.
If your program is doing a lot of system calls you may forget about
nice.

mac

 
 
 

The 'nice' program - getting more time for my program ?

Post by Achim Gra » Sat, 27 Jul 1996 04:00:00


    Richard> Specifics: Sun Sparc 5 running Solaris 2.5 with Perl
    Richard> version 5.  No other users on the system in both cases.

You are the only user on the system and your script is the only active
process.  What sort of speedup do you expect from tinkering with the
priority then?  I guess you did this because you're not seeing 100%
CPU utilization.  If you're doing I/O, during wait for I/O to become
ready the CPU is idle.  If you want to speed up your script (assuming
non 100% CPU utilization due to I/O) try slurping in all files into
memory.

--
Achim Gratz.

--+<[ It's the small pleasures that make life so miserable. ]>+--
WWW:    http://www.inf.tu-dresden.de/~ag7/{english/}

Phone:  +49 351 4575 - 325

 
 
 

The 'nice' program - getting more time for my program ?

Post by Alan Coopersmi » Sat, 27 Jul 1996 04:00:00



|So, now for my question - Is nice really doing anything for me ?
|I had hoped to get some significant (or at least "noticable :)
|speed-up but this was not the case.  mybigscript.pl does a
|lot of memory and CPU intensive work (looping through large
|arrays and such) and is not disk intensive at all.
|Does the priority affect CPU intensive tasks ?  Is there another
|way to get more CPU time for my task ?
|
|Specifics:
|  Sun Sparc 5 running Solaris 2.5 with Perl version 5.
|  No other users on the system in both cases.

If there's nothing else running on the system, where did you expect the
additional CPU time to come from?  'nice', et al. only let you take a
bigger chunk of CPU time from other processes - if there are no other
processes and you already have the entire CPU to yourself, there's nowhere
for it to get more CPU power from.

--
_______________________________________________________________________

The Open Computing Facility at the University of California at Berkeley

 
 
 

The 'nice' program - getting more time for my program ?

Post by Mark Fraz » Sat, 27 Jul 1996 04:00:00


Run 'top' and you'll probably see that you already have >95% of the
cpu time, as you mentioned that there are no other users.

mark
--
Mark Frazer   Electrical and Computer Engineering   University of Waterloo

 
 
 

The 'nice' program - getting more time for my program ?

Post by Andy Tucke » Sat, 27 Jul 1996 04:00:00



> 1) I ran my niftly PERL script as a regular user:
>         mybigscript.pl
>    Total time to run was 5 minutes 2 seconds

> 2) I ran the same script as root with the following:
>         nice --adjustment=-20 mybigscript.pl
>    Total time to run was 4 minutes 58 seconds

> So, now for my question - Is nice really doing anything for me ?

No.

Quote:> Specifics:
>   Sun Sparc 5 running Solaris 2.5 with Perl version 5.
>   No other users on the system in both cases.

Here's the key.  nice will do absolutely nothing unless there are
other processes running on the system.  If there are, it will give
the niced process(es) preferential treatment.  If the system is
otherwise idle, you'll get all the CPU time either way.

If you run two copies of your perl script at the same time, one niced,
you should see a difference.

--
Andy Tucker

Solaris Kernel Development
I speak only for myself, not SunSoft or Sun Microsystems.

 
 
 

The 'nice' program - getting more time for my program ?

Post by Richard D Holowcz » Sat, 27 Jul 1996 04:00:00


More fuel to the fire (so to speak).  After posting the
previous article, I came across the handy priocntl command.
Here's an experiment:

1)  Here I am as a regular user:

$ priocntl -l
CONFIGURED CLASSES
==================
SYS (System Class)
TS (Time Sharing)
   Configured TS User Priority Range: -60 through 60
IA (Interactive)
   Configured IA User Priority Range: -60 through 60

$ priocntl -e -c TS -p 60 ./bigscript.pl
1:14:42 Start to read entries.tab
1:14:44 Finished reading entries.tab
1:14:44 Processing...
1:19:37 Finished Processing. Ready to write entries.tab
1:19:39 Finished writing entries.tab

While this was running:
ps -c -u holowcza | grep "bigscript"
   PID  CLS PRI TTY      TIME CMD
 21776   TS  10 pts/0    4:30 bigscript
Actually, this fluctuated between 0, 10, 30 and 40

2)  Now, once again as root:

# priocntl -e -c TS -p 60 ./bigscript.pl
1:20:41 Start to read entries.tab
1:20:43 Finished reading entries.tab
1:20:43 Processing...
1:25:35 Finished Processing. Ready to write entries.tab
1:25:36 Finished writing entries.tab

While this was running:
# ps -c -u root | grep "bigscript"
 21804   TS  59 pts/0    0:29 bigscript
This stayed pegged at 59 the whole time (or at least as often as
I ran the ps command).

Same questions as in my previous post....why so little difference in
processing times ?
(Hope I'm not missing something really basic here...)

Rich H.

---

Rutgers University     http://cimic3.rutgers.edu/~holowcza/