× 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.



Nice one

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Haas, Matt
Sent: Wednesday, 18 May 2005 1:00 a.m.
To: RPG programming on the AS400 / iSeries
Subject: RE: Calling java from RPG - how to increase performance

Larry,

It sounds like a resource leak to me. You need to check to make sure
that you're cleaning up objects used by the transformer and parser
classes. I don't know if this is an issue or not but it sure sounds like
it. You should also make sure that jt400ntv.jar is in your classpath
since it has hooks into native (read that as faster) ways of accessing
certain things.

Concerning JDBC, the native driver is very fast compared to the cross
platform one in jt400.jar. Adding jt400ntv.jar to your classpath
automatically gets you the native driver.

I'd also make sure that you're up to date on Java and Database group
PTF's. There could be resource leaks that were addressed with PTF's.

Finally, what I've been told is that JNI does have a lot of overhead to
it. If all your RPG program does is call other Java methods, it seems
silly to me to call this from an RPG program. The toolkit has methods
for working with data queues so it shouldn't be difficult to take the
RPG program out of the picture. Of course, I don't know what all your
program is doing so it may not be an option but consider it something to
think about.

Matt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Larry Ducie
Sent: Monday, May 16, 2005 6:11 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Calling java from RPG - how to increase performance

Hi,
 
I have written a RPG service program that transforms XML [using
transform
stylesheets (XSLT)] into SQL insert statements. These are then executed
over
the database on the iSeries.
 
To do this I utilise the Java Native Interface (JNI) to create and use
java
objects. Basically, I create a transformer object. I then pass the
object an
XML stream source to transform, and a stream result to hold the
transformed
data.
 
For each transformation (assuming the transformer object does not
change) I
have to create a new StreamSource object:
 
To create the stream source object from RPG I have to perform the
following
steps:
 
1) Create a String object from the XML file path. (RPG-to-Java)
2) Create a File object from the String. (RPG-to-Java)
3) Free the String object - no longer needed. (RPG-to-Java)
4) Create a StreamSource object from the File object. (RPG-to-Java)
5) Free the File object - no longer needed. (RPG-to-Java)
 
I create a StreamResult object for each job that runs this process, so I
only perfrom the following once:
 
1) Create a String object from the result file path. (RPG-to-Java)
2) Create a File object from the String. (RPG-to-Java)
3) Free the String object - no longer needed. (RPG-to-Java)
4) Create a StreamResult object from the File object. (RPG-to-Java)
5) Free the File object - no longer needed. (RPG-to-Java)
 
Now, this all works fine - I'm just not sure it's running as fast as it
could be - approx 0.2 seconds for each transformation. After a few
hundred
transformations it seems to slow down - could this be the Garbage
Collector?
I start the JVM manually using JNI (with version 1.4.2 set). I also set
the
classpath manually (using putenv). The XML file path is retrieved from a
data queue, and the result file path is created by the program. 
 
So, what are the best ways to speed things up???
 
I've considered the following:
A) Create a custom java class that performs the conversions from file
path
to StreamSource/StreamResult and just call it with the two byte arrays.
B) Allocate more memory to the JVM - what's the best size? What's the
default size?
C) Run the whole process in java - I could execute the SQL using JDBC.
(but
would that just be even slower???)
D) I've not compiled the XML jar files (Xerces.jar, Xalan.jar, etc)
because
I believe the JIT compilers are better than CRTJVAPGM. Is this true?
E) I've not copied and compiled jt400.jar to put in my classpath -
should I
need to?
 
Basically, does the JNI carry a large overhead? Should I minimise the
number
of RPG-to-Java calls by writing a custom class? Should I optimise the
java
environment by allocating memory or compiling objects? I need your wise
words.
 
The program source is available if it helps. (We're running at V5R2M0)
 
Thanks
 
Larry Ducie

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.