PARAMETER DATASET with BY-REFERENCE

Posted by ericg on 08-Apr-2010 16:36

Hi there. Will I get any improved performance by including BY-REFERENCE in my calls below?

So the caller does this:

/* defines mydataset here */

. . .

/* retrieves data */

RUN bin/get.r (OUTPUT DATASET mydataset BY-REFERENCE).

/* make a change here */

. . .

/* special validation and commit */

RUN bin/set.r (INPUT-OUTPUT DATASET mydataset BY-REFERENCE).

/* display changes here */

. . .

/* end */

Note that these calling procedures are not persistent or super, if it matters.

Note that the caller procedure is run from a state-free AppServer agent by an OpenClient.

Thanks

All Replies

Posted by Tim Kuehn on 08-Apr-2010 17:30

as long as the target call is in the same session (and not to an appserver) by-reference will give you a substantial increase in performance since it'll be passing the PDS by reference and not doing a deep copy in order to do pass the reference by-value.

Posted by ericg on 08-Apr-2010 18:31

Thanks but I don't fully understand how calls are done when handled by

an appserver agent. As I said in my post, the main procedure (the whole

code in my post) would be run by an appserver agent (which is basically

a session) for the duration of the main procedure (requested by an

OpenClient). The two calls inside the main procedure would still be

contained inside the main session, therefore why wouldn't the

by-reference by valid even if run on the appserver by an agent?

Posted by Thomas Mercer-Hursh on 08-Apr-2010 18:55

Yes, the contrast is with a call between a client and the AppServer.  BY-REFERENCE is not meaningful there.

Posted by ericg on 09-Apr-2010 11:26

I see. In a non-distributed one appserver system, there wouldn't be any noticeable performance gain with using by-reference since the calls are within a single folder with no network issue. And it seems that the OpenClient via the proxy calls cannot use by-reference.

Posted by Tim Kuehn on 09-Apr-2010 11:41

Put it another way:

BY-REFERENCE will yield significant performance advantages w/in a session as the AVM can pass the PDS / TT by referring to a reference to those objects.

Whenever data crosses a session boundary - be it client -> appserver, appserver->client, appserver->non-ABL-connection, it's not possible to pass just a reference so BY-REFERENCE has no meaning and will not yield any improvements.

Posted by Thomas Mercer-Hursh on 09-Apr-2010 11:44

The core issue is that BY-REFERENCE means that you are passing a handle, not the actual table, so the caller and callee must share the same AVM for it to be meaningful.  The clever thing about BY-REFERENCE is that is you use it between AVM sessions, i.e., from a client to an AppServer agent, that it magically does the right thing and passes the physical table ... but, of course, with the consequent performance impact.  From an OpenClient to AppServer agent, not only do you have a network in between the two sessions, but one end is not an AVM, so they don't even have compatible ideas about what a temp-table is.

Posted by ericg on 09-Apr-2010 14:41

Okay so I can still use BY-REFERENCE for my procedure to procedure calls within an appserver session and therefore experience the gains. But not on calls leaving or entering the appserver to or from the client. At the same time I do recognize the possible impacts of using BY-REFERENCE from the documentation.

This thread is closed