'What is the best way to minimize the response from a cCALL statement in RPG?
We have a program which will be used by many other rpg programs. All process programs need to call this program to get a next counter number. As the program need to be loaded into memory and unloaded after every call, we may need some extra milliseconds for processing every time. Is there any better way to improve this process and keep the program in the memory to be readily available for call statement?
Solution 1:[1]
IBM i does not work like Windows or Linux. It has a flat address space that encompasses all RAM and disk space. Objects that are in use are moved to RAM and cached there until something else needs the space. If this program is used a lot, it will stay in RAM as long as you are not paging too much. Another thing that IBM i does is shares the program object. If you have 10 different jobs using this program concurrently, only on copy of it is paged into RAM, and all 10 jobs use it. This isn't something you typically need to worry about with IBM i, and if you do, the fix is to add RAM to reduce paging.
It occurs to me that you may not be talking about actually loading the program into memory and unloading once the program ends, but rather initializing on each call. RPG does not have to be initialized on each call, if you return from the program without setting on *INLR, files stay open and variables are not initialized on the next call. You do have to account for that in the program, but that can decrease the call cost of a program as well.
Or write it as a linear main program so you do not even have the cycle compiled into the program. (use ctl-opt main()
). Though I would expect that this is a small thing.
Solution 2:[2]
I would suggest implementing the program as service program. You can set up how it is stored as well while creating it with CRTSRVPGM.
Be careful on how you set it up tho, because otherwise you might compile every program that uses it again when you make a change. You need to create it with *DEFER, ALWUPD *YES and ALWLIBUPD *YES.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | jonii |