Docstoc

Natural Optimizer Compiler

Document Sample
Natural Optimizer Compiler Powered By Docstoc
					Natural
Optimizer
Compiler



            Faster Natural applications
            and lower CPU costs


            Presented By:
            Darrell Davenport
Today’s Agenda
 A Little About WSU
    Why we needed an optimizer
 What is NOC?
    How it works
 How Does NOC Work?
    Where it lives
    What it does to your programs
 How Do You Know If It Will Help Your Systems?
    The NOCSTAT command
 How to Install and Customize NOC
    Linking and setting parameters
    What OPTIONS are available
 DEMO
 Getting the Most From Natural
    Performance Programming tips

                2
About WSU
    Washington State University has been a Software AG
    customer for about 22 years. Nearly everything we do in
    the administrative side of the university uses Natural and
    Adabas. We have hundreds of applications and
    thousands of Natural programs.

   Payroll
   Registration
   Grades
   Financial Aid
   Accounting
   Property Inventory
   Student Records
   Retirement and Benefits
   And Many more...
                  3
About WSU
 We are a Mainframe centric installation. We were pushing our previous machine
  close to the limit.

 When it came time to move forward to the new Z-series machines, we could not
  afford to increase our service class. We bought a z-800 0A1.

 This meant we went from a dual processor to a single processor, and dropped a
  couple of points on the MIP scale. Our normal daily demand was within that
  capacity, but a few times per year, we exceed it. We knew we had to do
  something to get our most important business done on those peak days.

 NOC looked like a quick, easy, proven solution. Software AG’s NOC customers
  on SAG-L list serve reported approximately 30% better performance, although it
  varied by site and by program. We tested a sample batch Natural program and
  found the 30% factor about right.
                     4
What is NOC?                              +        NOC
                                                         =




NOC is a Natural add-on product specifically designed for maximizing
performance in your Natural Applications. It compiles Natural statements into
machine code.

Reduces CPU usage in Natural Programs (frees up CPU resources)

Reduces clock time and increases throughput for Natural batch jobs

Improves online response time (better transaction rate)



                     5
How Natural Optimizer Compiler Works


  Development                          Production
                    Natural Source



    Natural                            Natural
   Compiler
                    Natural Object
                                       Runtime
   Natural
                                       Natural
  Optimizer
                                      Bufferpool
  Compiler           Natural Object
                         plus
                    Optimized Code




                6
How Natural Optimizer Compiler Works

  In standard compile process Natural Source Code is translated into a Natural
   object code.

  This object code will be interpreted at runtime (e.g. in a production system)

  With Natural Optimizer Compiler switched on in a development environment,
   machine code is added to the Natural object code in an additional compile phase.

  Running NOC optimized programs in a production environment, this machine
   code is executed instead of interpreting normal Natural Object Code. (The
   optimizer is not needed in the production environment.)



                       7
How Natural Optimizer Compiler Works

 NOC compiles the following statements
    ESCAPE, COMPRESS, PERFORM, SEPARATE, EXAMIN (incl. Most
     Options) RESET, IF SELECTION
    Move statements:
        , MOVE ALL, MOVE UNTIL, MOVE INDEXED, MOVE (PM=I)
    Arithmetic statements:
        COMPUTE, ADD, SUBTRACT, MULTIPLY, DIVIDE,
    Conditional statements:
        IF, DECIDE
    Control statements:
        FOR, REPEAT
    Operand types are optimized:
        Parameter arrays and SUBSTRING operands


               8
How much will it do for me?


 It is easy to determine how much NOC will benefit your

 Natural application(s).   To find out, use the Natural

 NOCSTAT command.




                9
The NOCSTAT menu
15:47:09              ***** NATURAL NOCSTAT COMMAND *****
10/30/200

Name .................. ________
Library ............... MYLIB____

NOCable Objects only .. _

Output Report ......... X Statement Category
                        _ Statement Type
                        _ Code Profile

Output Destination .... X Screen
                        _ CSV to Work File 1
                        _ XML to Work File 1
                          with XSL
________________________________

Progress Control ...... X

                 10
 The NOCSTAT Utility
 3 different Output
 Destinations:                                        Workfile
                                                      (e.g. Excel)
 Your 3270 screen

14:00:59 *** NATURAL Machine Code Statistics *** 14.02.00
  Library: WHE      Program: NOCSTA4 Type: Mainprogrm

                     No NOC      NOCable
                    --------     --------
   Database Loop:          0            0
 Database Simple:          0            0
 SORT / WORK I/O:         31            0
    FOR / REPEAT:          0           14
Screen / Printer:         60            0
    String manip:          7           14
 Arith / Logical:          0          664
   Program calls:          3            0
   Control txfer:         51          113
     Block start:         25            0
 Set environment:          2            0
System functions:          0            0

             Total statements:       985
              NOC optimizable:       805
              Longest NOC run:       189 statements



                                                        XML
                                                        (e.g. web)
                                       11
                                                                           14:00:59 *** NATURAL Machine Code Statistics *** 14.02.00

The NOCSTAT Utility                                                          Library: WHE      Program: NOCSTA4 Type: Mainprogrm

                                                                                                No NOC        NOCable
                                                                                               --------       --------
                                                                              Database Loop:          0              0
3 different Output Formats:                                                 Database Simple:          0              0
                                                                            SORT / WORK I/O:         31              0
                                                                               FOR / REPEAT:          0             14
                                                                           Screen / Printer:         60              0

                                                             BY Category
                                                                               String manip:          7             14
                                                                            Arith / Logical:          0            664
                                                                              Program calls:          3              0
 Code Profile                                                                 Control txfer:
                                                                                Block start:
                                                                                                     51
                                                                                                     25
                                                                                                                   113
                                                                                                                     0
                                                                            Set environment:          2              0
 Mehr                                                                      System functions:          0              0
 14:26:40 *** NATURAL Machine Code Statistics *** 14.02.00
    Library: WHE      Program: NOCSTA4 Type: Mainprogrm                                 Total statements:           985
                                                                                         NOC optimizable:           805
                                                                                         Longest NOC run:           189 statements
 Source   Statement
 Line                                                                      Mehr
 ------   -------------------------                                        14:17:20 *** NATURAL Machine Code Statistics *** 14.02.00
 2070     MOVE/COMPUTE/ASSIGN         <-- NOC possible                       Library: WHE      Program: NOCSTA4 Type: Mainprogrm
 2080     EXAMINE
 2090     MOVE/COMPUTE/ASSIGN         <--   NOC   possible                 -------Statement--------       no NOC-   can NOC
 2090     IF                          <--   NOC   possible                 DB AT CONDITION                      6         0
 2090     MOVE/COMPUTE/ASSIGN         <--   NOC   possible                 MOVE/COMPUTE/ASSIGN                  0       481
 2090     MOVE/COMPUTE/ASSIGN         <--   NOC   possible                 READ/WRITE WORK FILE                31         0
 2095     COMPRESS                    <--   NOC   possible                 EXAMINE                              7         0
 2100     COMPRESS                    <--   NOC   possible                 COMPRESS                             0        12
 2105     MOVE/COMPUTE/ASSIGN         <--   NOC   possible                 WRITE                               51         0

                                                               By Type
 2110     ELSE/CLOSE LOOP             <--   NOC   possible                 INPUT                                3         0
 2110     IF                          <--   NOC   possible                 NEWPAGE                              2         0
 2110     MOVE/COMPUTE/ASSIGN         <--   NOC   possible                 REINPUT                              4         0
 2110     MOVE/COMPUTE/ASSIGN         <--   NOC   possible                 FIND                                 1         0
 2115     COMPRESS                    <--   NOC   possible                 READ                                 2         0
 2120     MOVE/COMPUTE/ASSIGN         <--   NOC   possible                 ELSE/CLOSE LOOP                      0        86
 2125     MOVE/COMPUTE/ASSIGN         <--   NOC   possible                 LOOPEND FOR/REPEAT                   0        13
                                                                           BLOCK START                         18         0
                                                                           ON ERROR                             1         0
                                                                           END                                  1         0
                                                                           STOP                                 2         0
                                                                           RETURN                               3         0
                                                                           RETURN INLINE                       15         0
                                      12
NOCSTAT.          Example output of “by category”.
15:55:27            ***** NATURAL NOCSTAT COMMAND *****         10/30/2003
               Library XDMD     Name CONVOBJ Type Program

                         No NOC    NOCable
                        --------   --------
      Database Loop:           1          0
    Database Simple:           3          0
    SORT / WORK I/O:           0          0
       FOR / REPEAT:           0          0
   Screen / Printer:           3          0
String Manipulation:           0          0
    Arith / Logical:           0         52
      Program Calls:           0          0
   Control Transfer:           1         13
        Block Start:           3          0
    Set Environment:           4          0
   System Functions:           0          0
      Miscellaneous:           0          0

               Total Statements:        80
                NOC optimizable:        65    ( Ratio: 81 % )
                Longest NOC Run:        31    Statements

                   13
NOC is Easily installed.
 Add NTOPT=ON and the desired settings for OPTIONS to
  your NATPARM module. (Or set session parameter OPT
  dynamically, for example with SYSPARM).

 Re-link the Natural nucleus and INCLUDE NOCNUC.

 You may need to increase the size of your bufferpool. The
  optimized code is added to the original modules, making them
  bigger.

 NOC disables the RECAT=ON function for GDA alignment.

                14
Easily customized (per session)
 Natural’s NOCOPT command makes it easy to customize the
 optimizer’s parameters.

User DMDSAC             - Optimizer Compiler Options -

Optimizer Compiler linked

        OPT Parameter at NATURAL Startup

        DIGTCHCK,INDX,OVFLW

        Current OPT Parameter Setting

        DIGTCHCK,INDX,OVFLW

  OPT = _____________________________________________________
Command ===>____________________________
               15
Easily customized
 The OPTIONS statement can be used to “bracket” statements
 within a program, allowing specialized targeting of specific code
 segments.

 OPTIONS MCG=(PGEN=ON)
 ...
 SET KEY PF12
 SET CONTROL 'W#C9L35F'
 REPEAT
 INPUT (AD=MIL'_' IP=OFF)
 ....
  OPTIONS MCG=(PGEN=OFF)
 ...
 END
                16
Easily customized
 NOC’s OPTIONS are:

   ABEND      Generate code to abend program if Natural dies.
   CACHE      Cache selected variables and parms for quick access.
   DIGTCHCK   Check zoned and packed fields for sign bytes
   ERRDUMP    Terminate compile if Natural encounters an abend.
   INDEX      Check array indexes for out-of-bounds conditions.
   INDX       Same as setting INDEX and RANGE parameters
   LOOPS      Generate loop-table entries (for undetermined targets)
   NODBG      Build code to allow Natural debugger to work or not.
   NOSGNTR    No sign translate done (from C to F); see also COMPOPT
   ON/OFF
   OPTLEV     Number of passes optimizer compiler does.
   PGEN       Can generate assembler code listing (and tracing)
   RANGE      Array range checks (E.G. move 1:3 to 5:6)
   SIGNCHCK   Check for negative zero after multiplication.
   ZD         Check for zero divisors to prevent NAT0954 abends.
                  17
Also has caching of variables.

 In addition to optimizing code into machine instructions, NOC

 will cache variables that are referenced several times, but not

 modified. This is only done for numerics, or arrays with the

 same index, or parameters.




                18
     DEMO




19
Demo program
FORMAT PS=60
*
 FIND LIB-DIRECTORY
   WITH DSNAME = #DSN
IF BREAK MEMBER /3/ SKIP 1 END-IF
FIND READ-FILE
   WITH DSNAME=#DSN
   AND MEMBER = MEMBER(0160)
   IF RECORD-NUMBER = 2
     EXAMINE RECORD FOR '.WSUMVS1' DELETE
     WRITE MEMBER(0210) RECORD (AL=44)
     ESCAPE BOTTOM (0210)
   END-IF
  END-FIND
END-FIND



                  20
Demo program’s NOCSTAT
Line    Statement
-----   -------------------------
0000    ON ERROR
0000    MCG OPTIONS
0010    MOVE/COMPUTE/ASSIGN         <-- NOCable
0160    FIND
0160    DB AT CONDITION
0190    IF                          <-- NOCable
0190    NEWPAGE
0210    FIND
0210    DB AT CONDITION
0240    IF                          <-- NOCable
0250    EXAMINE
0260    WRITE
0270    ESCAPE BOTTOM               <-- NOCable
0210    DB AT CONDITION
0290    ELSE/CLOSE LOOP             <-- NOCable
0160    DB AT CONDITION
0300    ELSE/CLOSE LOOP
                    21              <-- NOCable
Demo program’s NOCSTAT
No NOC      NOCable
                       --------    --------
      Database Loop:          0           0
    Database Simple:          0           0
    SORT / WORK I/O:          0           0
       FOR / REPEAT:          0           0
   Screen / Printer:          2           0
String Manipulation:          1           0
    Arith / Logical:          0           3
      Program Calls:          2           0
   Control Transfer:          1           3
        Block Start:          5           0
    Set Environment:          0           0
   System Functions:          0           0
      Miscellaneous:          0           0

               Total Statements:        18
                NOC optimizable:         6    ( Ratio: 33 % )
                Longest NOC Run:         0    Statements

                       22
Getting the most from Natural.

         There are things you can do to help make the program
         perform even better. These apply to all Natural programs,
         optimized or not.

        Doing the math-- dealing with numeric variables.
        Arrays -- Defining and processing arrays and tables.
        Work Files -- Reads and Writes, and validity checking.
        Strings and thing -- MOVE, INIT, RESET, etc.
        Local and System variables
        IF and DECIDE statements




                  23
Doing the Math

 Counters and Arithmetics should use packed (P) or Integer (I4) format. Indexes
  are best with (I4).

 Do not mix formats of (N), (P), (I), or (F) in conditionals (IF statements) or
  arithmetics.

 For ADD, SUBTRACT and IF, force numeric constants to have the same
  number of decimal places as the variable with the highest precision by adding a
  decimal place and trailing zeros, for example: ADD 1.00 TO #P(P7.2)




                      24
Arrays

 Whenever possible, use EXAMINE instead of a FOR loop to process arrays.

 MOVE #A(*) to #B(*) is much better than a FOR loop.

 To ease the optimization process, try to keep all scalar references at the front of
  the data section and all array references at the end of the data section.




                      25
Work Files

 By default the READ WORK statement selects, validates, and moves data from

 the buffer into the data area on a field by field basis. If you do not require field

 validation, use the RECORD option of the READ WORK statement. The CPU

 usage will be decreased dramatically.




                     26
Strings and things.

 Whenever possible use the RESET statement instead of the MOVE statement to

  blank or zero a field.

 When moving literal values to variables, or comparing variables to literal values,

  make the length of the alpha literal the same as the variable if the difference in

  length is not large. This will greatly speed up the operation.




                      27
Local and System variables

 When using DECIDE ON with (repeated reference to) a system variable, array

  or parameter operand1, it is more efficient to move the value to a scalar variable

  of the same type and length defined in the LOCAL storage section.




                     28
Decide and IF statements

 When coding DECIDE statements, put the most likely

  value/condition first, and use DECIDE ON FIRST whenever

  possible.




                29
Summary
We mass recompiled our top 25 major Natural applications,
(several thousand programs).

We did not recompile data areas or maps.

We have had no problems with our optimized applications.

Several programmers reported amazing results on their batch jobs.




                  30
 THANK
  YOU!
  Now,
 Time for
Questions!

             Contact Information:

             dmdsac@wsu.edu
             (509) 335-7316

             See you at the Natural Conference:

             www.naturalconference.com
             May 23 – 26, 2004
             Cambridge, Massachusetts

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:29
posted:3/11/2010
language:English
pages:31