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
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.
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?
Yes, the contrast is with a call between a client and the AppServer. BY-REFERENCE is not meaningful there.
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.
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.
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.
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.