Sorry to be so long responding to this. Been on the road to a new job.
My first suggestion is to (assuming v6r1) us the main keyword and not
include the RPG run time, IE use procedures. This makes the program smaller
and faster.
My main thing is to remember that ILE RPG is a C type language and like all
C type languages it very efficient at managing automatic (Local variables)
and very inefficient at managing static storage (Global variables). Static
storage takes resources to manage. The operating system is constantly
trying to trim down and allow room for other static storage. This is
expensive. automatic storage is created and destroyed each time that you
call a function. One machine language instruction creates all the storage
from the heap. and one deletes it. The only additional instructions are
initializing that storage to some value. as Barbara has said the RPG run
time is very efficient at doing this.
If you read books at about optimizing C programs what you see is again and
again. Cut down the amount of static storage. The same applies to ILE RPG.
Many years ago when Susan Gantner was still with IBM she wrote an article
all all this. Does anyone have a link to that article?
What this means in practice, of course, is using procedures and using them
properly. A procedure should perform a single function which you should be
able to describe without a conjunctive verb (And, Or). A side product of
this should be that each function should have a small number of variables.
You start having lots and lots of variables something is wrong.
In a monolith world you have a piece of code doing many things. In a C type
world (Structured Language), you many different functions doing one single
thing and being called many times or at least can be.
As Barbara has said, that is exactly what the ILE environment is meant to
do efficiently. Creating big monolith programs with hundreds of static
variables and nothing but subroutines to organize the code is the exact
opposite.
The other thing is to use service programs. In the time it takes to make
one program call you can call thousands and thousands of time to a
procedure in a service program and, of course, the above applies the same.
Rather than create one big function that does everything, break it down
into small procedures that do one thing.Service programs are so superior
because you can multiple entrance points to the code, IE procedures.
Of course I recommend that always use SQL. SQL may not give absolutely the
fastest times but if you only bring in what you need you are pulling a lot
less data through the buffers. The big thing is that if you can and need to
read multiple records this is where SQL will shine if you read all the
records at one time into an array or array mapped to a User Space. The
difference is huge.
The thing I think about when I am writing a program in ILE RPG is how would
I do this in C#, Java or C.There are many books on program design. I have
always found that a byproduct of a well designed program is an efficient
program..
Anyway, my option only.
On Thu, Jan 3, 2013 at 7:43 AM, RPGLIST <rpglist@xxxxxxxxxxx> wrote:
I'm looking for any and all suggestions on possible ways to speed up some
programs.
The typical ones that come to mind are:
1. avoiding open and closes on files
2. Not setting LR when calling a program or procedure multiple times
3. using Data structures for block reads and writes
Any other suggestions?
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.