Extremely slow startup performance

Marcus Lagergren marcus.lagergren at oracle.com
Wed Jul 2 10:18:13 UTC 2014


Hi Lang!

We are aware of there being a couple of warmup issues in Nashorn. My guess is that “coffee-script.js” is a fairly large script, Nashorn currently compiles everything to byte code and therefore takes time. 

In JDK9, the follow changes have already been checked in, that may help you:

* Lazy code generation policy on by default - less byte code generation
* Class caching - reuse of compiled classes
* Persistent code store on disk - basically identical code is never jitted more than once. If you compile identical source code, in these scripts, only the first run would be slow. This might help you out immensely. If you need the first run to go fast, we need to improve general warmup, and we are currently discussing how to do it. It’s on the table.

And the following that might make it a little bit worse, until we’ve had more time to property attack the warmup issues.

* Optimistic type optimization (may actually increase warmup)

These will be backported to 8u40.

What version of the JDK/nashorn are you using? Perhaps you could send us a Java Flight Recording of your recording of your slow startup, if you want us to look at it in detail. JFR files are always helpful.

Regards
Marcus

On 02 Jul 2014, at 11:21, Sia Lang <silverlanguage at gmail.com> wrote:

> I'm trying to use Nashorn as a plugin framework.
> 
> However, code like:
> 
>    engine.eval(new BufferedReader(new FileReader("coffee-script.js")));
> 
> easily takes 10-15 seconds. V8 uses a few milliseconds (when using jav8 as
> scriptengine)
> 
> In my opinion, Nashorn is so slow on startup it's useless (I have tons of
> plugin scripts, which accumulates to 2-3 minutes of application startup
> time due to nashorn - with v8 i'm subsecond!)
> 
> What's going on? Anything I can do to fix this?
> 
> Lang



More information about the nashorn-dev mailing list