On 03 Jan 2013 08:43, RPGLIST 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?
Design to...
Eliminate all coded waits; e.g. delays, such as with polling. There
is nothing worse than doing nothing instead of doing something, when the
goal is to get something done.
Eliminate almost all _object_ create and delete activity from
run-time; database members are object. Create an object only once, and
then keep that object effectively in perpetuity whenever possible. Use
temporary storage for data instead of using /objects/ e.g. *USRSPC. Even
if the objects are created in QTEMP, those objects in QTEMP are
/permanent objects/ regardless that they are seemingly temporary with
regard to scoping to the job.
Eliminate as much data-copy activity as possible. The data copy
could be explicit or by side effect of how a program is coded and how
the language compiler and the language run-time implements access to the
data. Note: Doing this improperly for parameter passing can allow for
many more problems than would be desirable, when extreme care is not taken.
Implement caching of data where appropriate; i.e. seldom-changing
values for which an easy test can be used to determine if the data has
changed since the last reference... either re-cache or defer to
non-cached references if data seems to be changing faster than expected
or is desirable for its impact to the algorithm.
Limit number of requests over a network; e.g. instead of asking once
for each of N rows of data from another node, ask once for all N rows of
data.
Eliminate contention of resources. If an operation need not be
mutually exclusive of other actions, then do not prevent concurrent
access; change the code to allow for that. When contention is correct,
then limit the wait times for timeout on the operations; waits on
contention are much like coded waits in that they are time spent doing
nothing.
Increase parallel operations. Refer back to contention for caveats.