Operating System - HP-UX
1846570 Members
1906 Online
110256 Solutions
New Discussion

Re: High CPU utilisation by a process

 
Amith_2
Frequent Advisor

High CPU utilisation by a process

Hello,

I am experiencing a problem where in one of my application programs which is written in COBOL is utilising a high percentage of CPU. The ouput of the 'top' command when the program is executed is as follows.
TIME %WCPU %CPU COMMAND
2:45 88.24 88.09 bgt205
The program continuously reads a file for records and process the record if available.
Could anyone suggest any method to reduce the CPU utilisation of the program.
10 REPLIES 10
Mahesh Kumar Malik
Honored Contributor

Re: High CPU utilisation by a process

Hi Amith

Please a look through the documentation for things such as required kernel changes and ulimit parameters required for application.

Regards
Mahesh
Bill Hassell
Honored Contributor

Re: High CPU utilisation by a process

The only way to reduce CPU usage is to rewrite the program. A simple 4 line script will use 100% of the CPU:

while :
do
:
done

The above script is working the way it was designed and no amount of kernel changing will ever fix this usage. There is nothing wrong with high CPU usage if it is what the program is supposed to do. Of course, the program may be using very inefficient methods to accomplish the processing, but that's for the programmer to fix.


Bill Hassell, sysadmin
Amith_2
Frequent Advisor

Re: High CPU utilisation by a process

Is there any method to monitor which call is taking up the CPU utilisation ?
RAC_1
Honored Contributor

Re: High CPU utilisation by a process

sar -c 2 5

You can also use tusc tool. Yu can get it here.

http://hpux.connect.org.uk

Anil
There is no substitute to HARDWORK
Andrew Merritt_2
Honored Contributor

Re: High CPU utilisation by a process

Or you could read the source code of the program and deduce how much CPU it will use. From your description, it sounds as though the problem may be one of design.

Are there any pauses or delays if the program reads the file and finds no records, or does it just read the file again? If the latter, then no wonder it is using a lot of CPU.

Andrew
vinod_25
Valued Contributor

Re: High CPU utilisation by a process

hi amith

use Glance plus to find out more details on process and cpu performance , which is real time and will give optimum results than top.

regards

Vinod K
Eknath
Trusted Contributor

Re: High CPU utilisation by a process

Hi Amith

It looks like the cobol program needs some changes. Is it possible to modify the program to read the file with some time gaps rather than reading continiously. I hope file you want to read may not be getting modified every millisecond.

Cheers!!!
eknath
Amith_2
Frequent Advisor

Re: High CPU utilisation by a process

Thanks for the answer.

Andrew,

The programs reads a file for a record , if there is no record then it will keep on browsing the file until it finds a record. Does such read calls increase the CPU utilisation ? What is the meaning of %WCPU utilisation in the top command?
Andrew Merritt_2
Honored Contributor

Re: High CPU utilisation by a process

Hi Amith,


> The programs reads a file for a record ,
> if there is no record then it will keep
> on browsing the file until it finds a
> record. Does such read calls increase
> the CPU utilisation ?

What do you mean by 'browsing the file'?

If the program is continuously doing something, it will be using CPU. If it reads the file, finds no records, and then just goes straight on to read the file again, it will be using a lot of CPU because the code is constantly executing.

My COBOL is extremely rusty, so I can't suggest the way to code it, but you want either a delay after failing to find any records, or some sort of read that won't return unless there is something there (not sure if COBOL has that).

WCPU is "weighted CPU", an average used by the scheduler. See http://forums2.itrc.hp.com/service/forums/questionanswer.do?threadId=57634

Andrew
Ted Buis
Honored Contributor

Re: High CPU utilisation by a process

I would consider getting Process Resource Manager and capping the amount of CPU that your process can get if you really think that it is wasting many cycles looping for nothing. That wouldn't involve any programming. If you have HP-UX 11i Enterprise Operating Environment, then you already have PRM.
Mom 6