View previous topic :: View next topic
|
Author |
Message |
anoopn1985
New User
Joined: 23 Apr 2007 Posts: 16 Location: tvm
|
|
|
|
Hi,
Cobol driver program calling a subprogram 1million times. If we call the subprogram as static, will it improve performance a lot?
How dynamic call works, if we have 1million call statements? Will it load the load module into memory during each call? What are the difference between loading the load module and working storage memory allocation in static and dynamic calls? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
There is a link to manuals at the top of the page. Click on it, find the COBOL Programming Guide manual, and read section 4.1.3.4 titled Performance considerations of static and dynamic calls. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Is this Batch or CICS?
Bill |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
A CICS program calling a subprogram a million times???
Oh, the mental image this gives me ... what a way to start a Monday! |
|
Back to top |
|
|
anoopn1985
New User
Joined: 23 Apr 2007 Posts: 16 Location: tvm
|
|
|
|
this is batch. Can anyone help me on this? |
|
Back to top |
|
|
anoopn1985
New User
Joined: 23 Apr 2007 Posts: 16 Location: tvm
|
|
|
|
I already gone through the manuals given but didn't get an exact answer. My question is if I have 1million calls to a subprogram, then which call is better, static or dynamic? Also how dynamic call works? Will it load program to memory each time? |
|
Back to top |
|
|
anoopn1985
New User
Joined: 23 Apr 2007 Posts: 16 Location: tvm
|
|
|
|
Will dynamic call load the program into memory 1million times or onle 1 time? |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
How the sub-program access is controlled by the main-program is via the Compile option DYNAM/NODYNAM.
If there are other sub-program's currently being called by the main-program, then the use of this option will have an affect on all other sub-programs.
When called DYNAMICALLY, the load module (sub-program) is fetched one time by the operating system and remains in memory until JOB/STEP termination or the main-program issues a CANCEL.
Bill |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
the manual gives you the answer. re-read.
if you only called the sub-program once, an argument could be made,
but a million times, no arguments. go dynamic.
keeps your load module size smaller.
easier to maintain the code.
and as Robert indicated: this better not be cics.
Bill,
I belive the dynam/nodynam options have to do with how a module is called.
if i am a mainprogram and I call 4 modules statically and 2 modules dynamically,
it does not matter what the dynam/nodynam option is for the mainprogram.
a CALL variable will always result in a dynamic CALL.
depending upon the compile/link edit options,
a CALL literal could be static or could be dynamic. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Either you did not read the manual reference I cited, or you cannot understand plain written English -- I'm not sure which:
Quote: |
4.1.3.4 Performance considerations of static and dynamic calls
Because a statically called program is link-edited into the same load module as the calling program, a static call is faster than a dynamic call. A static call is the preferred method if your application does not require the services of the dynamic call. |
How did you NOT get an exact answer from this manual quote?
Quote: |
How dynamic call works, if we have 1million call statements? |
The same way if you have 1 call statement -- unless you use CANCEL. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Thanks Dick. CRS must be kicking in. Plus, I haven't done Batch for quite some time so the rust is showing....
Bill |
|
Back to top |
|
|
anoopn1985
New User
Joined: 23 Apr 2007 Posts: 16 Location: tvm
|
|
|
|
Dick,
"if you only called the sub-program once, an argument could be made,
but a million times, no arguments. go dynamic. "
Here I'm confused. In static, there will be only one link-edited load for driver and subprograms and hence its faster. So if there is 1million calls, the static call will be effective rt? I agree that static will take more memory.
Also how the working storage memory is allocated in Dynamic calls? Will it allocate the subprogram memory seperately for each 1milloin calls? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
From section 4.1.3.2 of the COBOL Programming Guide manual (link at the top of the page):
Quote: |
The first dynamic call to a subprogram within a run unit obtains a fresh copy of the subprogram. Subsequent calls to the same subprogram (by either the original caller or any other subprogram within the same run unit) result in a branch to the same copy of the subprogram in its last-used state, provided the subprogram does not possess the INITIAL attribute. Therefore, the reinitialization of either of the following items is your responsibility:
GO TO statements that have been altered
Data items |
|
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
anoopn1985 wrote: |
I agree that static will take more memory.
|
Static calls will not take more memory if you call every submodule at least once.
The advantage in memory usage with dynamic calls is for modules that you may conditionally call during execution. If they are not called, they don't have to be fetched.
Conditional calls will save some space in load libraries as every load module will not have to include the executable code.
On the other hand, dynamic calls will make it harder to cross reference module usage. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
dynamic calls will make it harder to cross reference module usage.
|
standards allow for easy trapping/searching of calls.
CALL WS-DLC1932
would be a dynamic CALL to module DLC1932.
mapping for table driven dynamic calls
(where program name is contained in a db2 column)
can be easily generated using a db2 unload mechinism with SQL,
and then DFSORT/ICETOOL control statemens to parse and generate a cross listing.
I just finished a little pet-project where xrefs are created
(accurately, I may add)
purely with DB2 dumps and SUPERC results being parsed by DFSORT.
No cobol or rexx was necessary.
I had to create something that anyone could follow and execute the jobs.
but, agreed, static calls are much easier to cross-reference. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Just a correction of my own post...
Kjeld wrote: |
Conditional calls will save some space in load libraries as every load module will not have to include the executable code. |
Dynamic calls will save some space in load libraries as every load module will not have to include the executable code.
And I agree with Dick, proper standards can make x-referencing easier, but if legacy code is from different ages and organisations you might have to resolve calls on a module to module basis. |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
dbzTHEdinosauer wrote: |
CALL WS-DLC1932
would be a dynamic CALL to module DLC1932. |
While one might ASSUME that to be true, in actuality what you say would only be true if the variable named WS-DLC1932 contained the value 'DLC1932 ' at the time of the CALL. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
That's where adherence to the programming standards comes in
The example can only be used if the call is unconditional: That call will only call that module. It could as well have been substituted with a static call. |
|
Back to top |
|
|
|