× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 10/12/06, Barbara Morris <bmorris@xxxxxxxxxx> wrote:
Steve Richter wrote:
>
> we are talking RPG, the predominant language on the i5. Limitless
> arrays have to exist on the heap. Standard RPG arrays are allocated on
> the call stack. It takes more CPU to alloc from the heap than from the
> call stack.  Once you alloc from the heap you have to run cleanup code
> to dealloc the limitless array. To do that correctly you probably have
> to run CEERTX to make sure all the allocations are freed. This sort of
> thing takes more CPW to do. You can argue how much, but you make no
> sense if you are saying there is no impact.
>

I have a program that measures the speed of different RPG operations.
Here are some results ( the elapsed time is milliseconds ):

NoPass 50000 Begin 10.23.25 End 10.23.25  Elapsed 42
NoPass control 50000 Begin 10.23.25 End 10.23.25  Elapsed 44
NoPass 50000 Begin 10.23.25 End 10.23.25  Elapsed 41
PassByValue 150000 Begin 10.23.25 End 10.23.25  Elapsed 107
PassByRef 150000 Begin 10.23.25 End 10.23.25  Elapsed 100
CeeRtx 50000 Begin 10.23.25 End 10.23.26  Elapsed 439
Procedure call 50000 Begin 10.23.26 End 10.23.26  Elapsed 36
qusrobjd 3500 Begin 10.23.26 End 10.23.27  Elapsed 989
alloc 50000 Begin 10.23.27 End 10.23.27  Elapsed 254


Steve, at runtime, there is lots of heap allocation going on under the
covers, some in the RPG runtime, some in the system.  There is also lots
of cancel handling.  If IBM decided that RPG should have unbounded
arrays, the fact that it might require additional heap allocation and
cancel handlers would not be a deterrent to providing that support.

Barbara, my working assumption on this is that CEERTX is not used
within compiler generated code in order to do procedure exit cleanup.
It is probably used when the Monitor ... EndMon opcodes are used. In
contrast, an ILE C++ program would have to use it on all function
calls. Otherwise how could the compiler guarantee that destructors
would fire when an exception thrown over a procedure causes that
procedure to be shutdown?

My assumption is that when the compiler uses %alloc in a procedure it
has to call CEERTX in that procedure in order to make sure that
everything that is allocated from the heap is deallocated.

The next assumption is that an unbounded array would be allocated on
the heap. Meaning that the use of an unbounded array in a procedure
would require the procedure call CEERTX on entry.   All guesswork.
Dont anyone jump out the window. Based on my timings, calling a shell
procedure that uses CEERTX takes 10x the CPU than without. So a
procedure that used an unbounded array would take longer to call than
one that uses a standard array.

(The V5R4 XML support uses heap allocation and cancel handlers.
XML-INTO sometimes takes quite a bit of time to run depending on the
size of the XML document, but very little of the time is related to
either heap allocation or cancel handling.)

Are you sure that the time to allocate from the call stack is faster
than allocating from the heap?  How can you tell?  (I don't know whether
it is or not, but I doubt that it's a significant difference.)

my guessing here is that procedure variables are allocated on the
stack in one swoop when the procedure is called. Heap allocations are
done one at a time as the procedure is running.  From my measurements
the alloc .. dealloc pair takes 6x the time of a procedure call.

-Steve

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.