Hi,

I've been using Inline::Java, apparently with great success (no errors), for 
around a year. The Perl script is using a vendor's JAR file to do automated 
system administration on the vendor's application server. I have been using 
Perl with forks.pm to make changes to multiple servers in parallel, using 
SHARED_JVM => 1.

Since we added new servers, users have been complaining that the Perl scripts 
are taking a lot longer. After a lot of logging and testing, I discovered that 
the Inline::Java module is the bottleneck. Even though the threads appear to be 
running in parallel, the actual time taken is approximately equal to 
single-threaded performance. I.e.

   Time to run Java threads =  (# threads) x (time to run one Java thread)

Looking at the implementation of Inline::Java, I can see that a large # of the 
Java methods are declared as synchronized. I.e.

   cd ~/.cpan/build/Inline-Java-0.52
   find . -name '*.java' -exec grep synchronize {} \;

It appears that when calling Java methods using the module, only one method can 
only be run at any given time, forcing single-threaded performance. The vast 
majority of time in my Perl script is spent waiting for the application server 
Java methods to respond, thus this synchronization is the key bottleneck.

Is there any way to work-around this issue? Can the Inline::Java::Server be 
made to run as multiple processes, so that I can get each Perl thread to 
connect with its own JVM? Why do all the Java methods inside the module need to 
be synchronized?

I haven't tried JNI, but I would be willing to if it would help. However, my 
thought is that is that JNI wouldn't help here. Can anyone confirm?

Any help greatly appreciated!

BTW - Could the package maintainer please mention this limitation in the POD? 
The discussion of SHARED_JVM mentions using Inline::Java with mod_perl. 
However, this limitation could be a serious impediment to performance in such 
an environment.

Thanks,
Scott

Reply via email to