Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaCompiler API - slow compilation when running in tomcat

My application generates java code during runtime and compiles it using the JavaCompiler API. Some of the generated files can be rather large - up to a few hundred thousand lines. I find that when I run the javac command on the generated code in the command line, or alternatively if I use an application that does just the compilation via the JavaCompiler API, I can compile many of these files (~500), even if they are very large, in under two minutes. However, if I call the API via my application when it is running on a Tomcat server, the compilation time runs upwards of twelve minutes (!!!).

I would appreciate any suggestions on how to improve the performance of the compilation.

Thanks!

like image 294
Jewels Avatar asked Jun 29 '16 12:06

Jewels


1 Answers

Try to set the thread priority to the highest value (on the thread or thread pool):

setPriority(Thread.MAX_PRIORITY);
like image 124
volatile Avatar answered Nov 15 '22 14:11

volatile