Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need help in tuning Compute Statement - performance

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
vijikesavan

Active User


Joined: 04 Oct 2006
Posts: 118
Location: NJ, USA

PostPosted: Wed Jul 11, 2007 8:05 pm    Post subject: Need help in tuning Compute Statement - performance
Reply with quote

Hi,
We have a highly CPU intensive program and we executed strobe on it.
The report pointed to a COMPUTE statement as contributor to CPU.

The statement:
Code:
COMPUTE WS-VALUE =                     
  (PRD-FCR-AM * PRD-AMZ-AM *   
    PRD-CLS-PX * LOT-QY)       


The PIC clause:
Code:
05  WS-VALUE      PIC S9(13)V9(5) COMP-3.       
05  PRD-FCR-AM    PIC S9(14)V9(4) COMP-3.       
05  PRD-AMZ-AM    PIC S9(4)V9(14) COMP-3         
05  PRD-CLS-PX    PIC S9(9)V9(9) COMP-3         
05  LOT-QY        PIC S9(14)V9(4) USAGE COMP-3. 


"WS-Value" is also 10 bytes which makes me feel the results can get truncated but have no clue on its CPU usage. Though strobe report says, this piece is consuming high CPU, I am not convinced and looking for some answers.

Can anyone clarify me on this?
Appreciate your time.

(I wanted to run the program commenting this statement to verify, but I donot have access to a certain table the program accessing)
Thanks,
Viji
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Jul 11, 2007 9:25 pm    Post subject: Re: Need help in tuning Compute Statement - performance
Reply with quote

vijikesavan wrote:
Code:
COMPUTE WS-VALUE =                     
  (PRD-FCR-AM * PRD-AMZ-AM *   
    PRD-CLS-PX * LOT-QY)       


The PIC clause:
Code:
05  WS-VALUE      PIC S9(13)V9(5) COMP-3.       
05  PRD-FCR-AM    PIC S9(14)V9(4) COMP-3.       
05  PRD-AMZ-AM    PIC S9(4)V9(14) COMP-3         
05  PRD-CLS-PX    PIC S9(9)V9(9) COMP-3         
05  LOT-QY        PIC S9(14)V9(4) USAGE COMP-3. 

FWIW, make sure you have the optimizer on and the number of digits should be odd for all the variables.
If possible, reduce the digits behind the decimal to the number in the result field, anything beyond the V9(5) will never be taken into account.
Greater speed will result in the use of 15 or less digits total.
It might be interesting to see if the following didn't speed things up:
Code:
05  WS-VALUE      PIC S9(13)V9(05) COMP-3.
05  PRD-FCR-AM    PIC S9(14)V9(04) COMP-3.
05  PRD-AMZ-AM    PIC S9(04)V9(14) COMP-3
05  PRD-CLS-PX    PIC S9(09)V9(09) COMP-3
05  LOT-QY        PIC S9(14)V9(04) COMP-3.
05  PRD-FCR-AMI   PIC SV9(05) COMP-3.     
05  PRD-AMZ-AMI   PIC SV9(05) COMP-3     
05  PRD-CLS-PXI   PIC SV9(05) COMP-3     
05  LOT-QYF       PIC SV9(05) COMP-3.     
05  PRD-FCR-AMF   PIC S9(15)V COMP-3.     
05  PRD-AMZ-AMF   PIC S9(15)V COMP-3     
05  PRD-CLS-PXF   PIC S9(15)V COMP-3     
05  LOT-QYF       PIC S9(15)V COMP-3.     
               

Code:
MOVE PRD-FCR-AM TO PRD-FCR-AMI           
MOVE PRD-AMZ-AM TO PRD-AMZ-AMI           
MOVE PRD-CLS-PX TO PRD-CLS-PXI           
MOVE LOT-QY     TO LOT-QYI               
MOVE PRD-FCR-AM TO PRD-FCR-AMF           
MOVE PRD-AMZ-AM TO PRD-AMZ-AMF           
MOVE PRD-CLS-PX TO PRD-CLS-PXF           
MOVE LOT-QY     TO LOT-QYF
COMPUTE WS-VALUE =                     
    (PRD-FCR-AMI * PRD-AMZ-AMI * PRD-CLS-PXI * LOT-QYI)
 + (PRD-FCR-AMF * PRD-AMZ-AMF * PRD-CLS-PXF * LOT-QYF)     
Back to top
View user's profile Send private message
vijikesavan

Active User


Joined: 04 Oct 2006
Posts: 118
Location: NJ, USA

PostPosted: Wed Jul 11, 2007 11:00 pm    Post subject: Re: Need help in tuning Compute Statement - performance
Reply with quote

Thanks William.
I will change the code accordinlgy and pass it to the group who has access to test.
Will post the results soon I get..
Eagerly waiting to see some improvements.

Thanks,
Viji
Back to top
View user's profile Send private message
vijikesavan

Active User


Joined: 04 Oct 2006
Posts: 118
Location: NJ, USA

PostPosted: Wed Jul 11, 2007 11:34 pm    Post subject: Re: Need help in tuning Compute Statement - performance
Reply with quote

Hi William,
I think the results won't match. I might be wrong.
for example,
A=10.5, B=12.3 and C=9.5
A*B*C = 10.5*12.3*9.5 = 1226.925

whereas,
(10*12*9)+(0.5*0.3*0.5) = 1080+0.075 = 1080.075

Am I missing something? pls help.
Thanks,
Viji
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Jul 11, 2007 11:39 pm    Post subject:
Reply with quote

Yup, ya got me....I guess I didn't have my head screwed on tightly.... icon_redface.gif
Let me think on it a little....
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jul 11, 2007 11:50 pm    Post subject:
Reply with quote

Hello,

What kind of processing is happening in this program? If the majority of the code is a read, some moves, this calculation, and a write, the posted compute will surely be the bit of code the largest cpu use.

Is this necessarily a problem?
Back to top
View user's profile Send private message
vijikesavan

Active User


Joined: 04 Oct 2006
Posts: 118
Location: NJ, USA

PostPosted: Wed Jul 11, 2007 11:59 pm    Post subject: Re: Need help in tuning Compute Statement - performance
Reply with quote

Yes. The program reads 2 input files and DB2 database and based on few conitions the WS-Value is calculated.
This job runs for around 30 mins with 10 mins CPU. Though it might look ok, but this job shows growing trend for the past 1 year.
The volume of data it is processing didnot increase much, but the job used to take just 5 mins of CPU and it is now taking 10mins of CPU.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jul 12, 2007 12:28 am    Post subject:
Reply with quote

Hello,

Does the amount of cpu time grow with each run or have there been a few "jumps" in usage? How much intermediate cpu usage info is available? Are there enough "footprints" to tell what changes occurred when the cpu usage began to rise? Has the size of these fields that are used in the calculation been increased?

How are values put iinto these fields?
Code:
05  PRD-FCR-AM    PIC S9(14)V9(4) COMP-3.       
05  PRD-AMZ-AM    PIC S9(4)V9(14) COMP-3         
05  PRD-CLS-PX    PIC S9(9)V9(9) COMP-3         
05  LOT-QY        PIC S9(14)V9(4) USAGE COMP-3. 

14 digits on either side of the decimal is not normal - as a test can you create new fields with less digits on either side of the decimal for the 3 fields that now have 14 digits specified (and as Bill suggests, make sure the number of digits is odd, preferable 15 or less)? I'm also wondering about the 9.9 field as very seldom are 9 digits after the decimal meaningful. The most extreme case i've personally been involved with was pricing many millions of board-feet of lumber times .0012357 per board foot. That didn't take 9 digits to the right of the decimal and we had to round to the next cent anyway. . .
Back to top
View user's profile Send private message
vijikesavan

Active User


Joined: 04 Oct 2006
Posts: 118
Location: NJ, USA

PostPosted: Thu Jul 12, 2007 12:42 am    Post subject: Re: Need help in tuning Compute Statement - performance
Reply with quote

Thanks Dick.
I am changing the code making the fields to have odd numbers (15 or less).

Regarding the 9.9 field I agree with you I too feel the same, but I need to get consent from business as how many positions I can reduce.

The CPU usage is growing steadily and there are no jumps. No code changes recently.

Letme try this and get back to you.

Thanks for all your suggesstions.
Viji
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Jul 12, 2007 12:55 am    Post subject: Re: Need help in tuning Compute Statement - performance
Reply with quote

From What I understand, the optimizer can take duplicate portions of computes (from the left side or withing parens) and carry the intermediate results through multiple calculations.....

It might be interesting to see which works best.

- Important -
The optimizer must be used and 15 or fewer digits in the PICTURE specification to avoid using library routines for multiplication.
Code:

05  AI            PIC S9(15)V COMP-3.         
05  BI            PIC S9(15)V COMP-3           
05  CI            PIC S9(15)V COMP-3           
05  DI            PIC S9(15)V COMP-3.         
05  AF            PIC SV9(07) COMP-3.         
05  BF            PIC SV9(07) COMP-3           
05  CF            PIC SV9(07) COMP-3           
05  DF            PIC SV9(07) COMP-3.         
                                               
MOVE PRD-FCR-AM TO AI                         
MOVE PRD-AMZ-AM TO BI                         
MOVE PRD-CLS-PX TO CI                         
MOVE LOT-QY     TO DI                         
MOVE PRD-FCR-AM TO AF                         
MOVE PRD-AMZ-AM TO BF                         
MOVE PRD-CLS-PX TO CF                         
MOVE LOT-QY     TO DF                         
                                               
COMPUTE WS-VALUE = BI * DI * CI * AI           
COMPUTE WS-VALUE = BI * DI * CI * AF + WS-VALUE
COMPUTE WS-VALUE = BI * DI * CF * AI + WS-VALUE
COMPUTE WS-VALUE = BI * DI * CF * AF + WS-VALUE
COMPUTE WS-VALUE = BI * DF * CI * AI + WS-VALUE
COMPUTE WS-VALUE = BI * DF * CI * AF + WS-VALUE
COMPUTE WS-VALUE = BI * DF * CI * AI + WS-VALUE
COMPUTE WS-VALUE = BI * DF * CI * AF + WS-VALUE
COMPUTE WS-VALUE = BF * DI * CI * AI + WS-VALUE
COMPUTE WS-VALUE = BF * DI * CI * AF + WS-VALUE
COMPUTE WS-VALUE = BF * DI * CF * AI + WS-VALUE
COMPUTE WS-VALUE = BF * DI * CF * AF + WS-VALUE
COMPUTE WS-VALUE = BF * DF * CI * AI + WS-VALUE
COMPUTE WS-VALUE = BF * DF * CI * AF + WS-VALUE
COMPUTE WS-VALUE = BF * DF * CI * AI + WS-VALUE
COMPUTE WS-VALUE = BF * DF * CI * AF + WS-VALUE
                                                                 
COMPUTE WS-VALUE = BI * DI * CI * AI                             
                 + BI * DI * CI * AF                             
                 + BI * DI * CF * AI                             
                 + BI * DI * CF * AF                             
                 + BI * DF * CI * AI                             
                 + BI * DF * CI * AF                             
                 + BI * DF * CI * AI                             
                 + BI * DF * CI * AF                             
                 + BF * DI * CI * AI                             
                 + BF * DI * CI * AF                             
                 + BF * DI * CF * AI                             
                 + BF * DI * CF * AF                             
                 + BF * DF * CI * AI                             
                 + BF * DF * CI * AF                             
                 + BF * DF * CI * AI                             
                 + BF * DF * CI * AF                             
                                                                 
COMPUTE WS-VALUE = BI * (DI * (CI * (AI + AF)) * (CF * (AI + AF)))
                 + BI * (DF * (CI * (AI + AF)) * (CF * (AI + AF)))
                 + BF * (DI * (CI * (AI + AF)) * (CF * (AI + AF)))
                 + BF * (DF * (CI * (AI + AF)) * (CF * (AI + AF)))
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jul 12, 2007 2:09 am    Post subject:
Reply with quote

Hello,

Quote:
Regarding the 9.9 field I agree with you I too feel the same, but I need to get consent from business as how many positions I can reduce.

The CPU usage is growing steadily and there are no jumps. No code changes recently.

Yup - surely best to get the word from "the business" before reducing the size(s).

Is it possible that volume has been increasing (money and quantity values if not number of transactions)? Has the elapsed time remained fairly constant or has it also gone up? The fields used in this COMPUTE have had the same definition for the past year?
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 149
Location: Ottawa Canada

PostPosted: Thu Jul 12, 2007 2:42 am    Post subject:
Reply with quote

Just a quick note: When rounding can occur we stay clear of the COMPUTE statement and instead use separate statements for each operation such as MULTIPLY and DIVIDE. This way you can be in complete control of how the intermediate variables get defined (ie number of digits after decimal point).

In your case, this advice may not be necessary as you do not do any division so perhaps COMPUTE works fine. Just beware.

In situation where you multiply and divide - all within the same COMPUTE
statement - you can easily get incorrect results due to rounding. The COMPUTE statement uses intermediate variables - the datatypes of these intermediate variables are decided by the compiler.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Batch job tuning sgandhla Testing & Performance analysis 5 Fri Mar 24, 2017 9:41 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts BC, BCR, BRC, BRCL performance steve-myers PL/I & Assembler 0 Fri Dec 23, 2016 7:44 am
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us