Calling Internal Procedures: Performance impact?

Posted by jmartin104 on 19-Jan-2018 08:52

In general, are there any performance impacts of calling IPs?

All Replies

Posted by onnodehaan on 19-Jan-2018 08:55

I would say so, but very very very very very little per call

Posted by onnodehaan on 19-Jan-2018 08:56

perhaps you can provide a bit more background?

Posted by dbeavon on 19-Jan-2018 09:02

I would say measure it.  Do 1,000 or 10,000 in a loop.  

At a these magnitude I'd guess it will start consuming a second or more of time.  It certainly isn't free since OE does a bit of work at run-time to evaluate parameters and such.  In the old days we used to put a lot of code in ABL include files so that we would avoid the run-time performance penalties of calling new procedures.

It may depend on factors such as whether you are using "shared variables", or procedure parameters .

Posted by Brian K. Maher on 19-Jan-2018 09:04

One possible issue is when passing datasets or temp-tables around. By default we pass by value which means we deep copy (clone) the data abnd this can be expensive.  We provide ways around that (by-reference, bind, etc).
 
Other than the above I would say write your code for understandability and mantainability first, optimize later if required.

Posted by onnodehaan on 19-Jan-2018 09:06

yes, optimization as last step.

But up front: don't use global or shared variables :-)

Posted by OctavioOlguin on 19-Jan-2018 09:11

then use a lot of IP, as they clarify programming, and when you master IP, then move to OO, lots of slower performance, but you´ll shine inside your company,,

Posted by Peter Judge on 19-Jan-2018 09:32

If you are passing TT data inside a persistent proc (between IP’s) then the TT is not passed by value.  If you pass between .P’s (and classes) then you make a deep copy. I’m not sure what happens with SUPER-PROCEDUREs.
 
You can verify this via the TEMP-TABLES log-entry-type. See attached test code. This produces a log like the below. You can see 2 temp-tables created – one in each .P.
 
[18/01/19@10:30:07.538-0500] P-014820 T-008476 2 4GL TEMP-TABLE     Created TEMP-TABLE ttData (ID:7 NO-UNDO Indexes:1) C:\devarea\views\pjudge_OE117\vobs_possenet\tests\test_pp_tt.p @ 34
[18/01/19@10:30:07.538-0500] P-014820 T-008476 1 4GL APPL           IN P1
[18/01/19@10:30:07.538-0500] P-014820 T-008476 1 4GL APPL           IN P2
[18/01/19@10:30:07.538-0500] P-014820 T-008476 1 4GL APPL           IN P3
[18/01/19@10:30:07.538-0500] P-014820 T-008476 1 4GL APPL           IN P4
[18/01/19@10:30:07.554-0500] P-014820 T-008476 1 4GL APPL           NOW EXTERNAL
[18/01/19@10:30:07.554-0500] P-014820 T-008476 2 4GL TEMP-TABLE     Created TEMP-TABLE ttData (ID:8 NO-UNDO Indexes:1) p1 test_pp_tt2.p
[18/01/19@10:30:07.554-0500] P-014820 T-008476 1 4GL APPL           EXTERNAL START
[18/01/19@10:30:07.554-0500] P-014820 T-008476 1 4GL APPL           EXTERNAL END
 
 
 

Posted by jmartin104 on 19-Jan-2018 12:32

Brian, I agree and always try to balance maintainability and understanding with performance. Are you saying a call to an IP (located inside the calling procedure) still makes a copy?

Posted by jmartin104 on 19-Jan-2018 12:35

Sorry, my question was a bit vague, wasn't it. If my .p calls and IP in the same .p, are there performance (significant) impacts? For example:

test.p

run mytest in this-procedure (input temp-table-cust).

procedure mytest:

...

Posted by Brian K. Maher on 19-Jan-2018 12:36

I was wrong about that.  Calls to either an external .p or an internal procedure of a .p which is loaded persistently will do the csopy.
 
Sorry about that.  I shouldn’t try to do three things at a time.  :(

This thread is closed