Any plans for optimizing engine.eval() ?

Hannes Wallnoefer hannes.wallnoefer at oracle.com
Wed Sep 24 20:55:28 UTC 2014


Hi Roland,

Given that you execute all scripts only once, most of the Nashorn 
execution time is probably spent in compilation and linking of 
invokedynamic callsites. Although Nashorn is faster than Rhino once it 
is warmed up, it takes longer to get there. In other words: If you run 
your scripts more than once you should eventually see Nashorn getting 
faster.

That said, I'm a bit surprised about how much the numbers diverge. Would 
it be possible to let us see the code you are running? This way we might 
be able to give you advice on how to improve performance, or it may help 
us to find bottlenecks in Nashorn.

Thanks,
Hannes

Am 2014-09-24 um 11:12 schrieb Houtman, Roland:
> Hi Dev,
>
> The first time a script is run, Nashorn seems to rely on the interpreting the script. But it isn't performing as Rhino did (at all).
> I've tried the engines coming with the following JDK's
> JDK 1.7u45
> JKD 1.8u20
> JDK 1.8.0_40 (build 6)
>
> The time I measured is the total execution time of 200 separate instances with all different scripts, all running only once.
> (The test script is a nothing more than getting an object from an array, do an if/else, and storing the result in another array.)
>
> --
> JDK 1.7u45 CompiledScript.eval()	219 msec
> -
> JKD 1.8u20 CompiledScript.eval()	13613 msec
> JDK 1.8u20 Engine.eval()		14002 msec
> -
> JDK 1.8.0_40 CompiledScript.eval()	26396 msec
> --
>
> I notice that it takes up to 60 seconds before Nashorn is ready creating&loading classes to run, and running at good speed.
> In that timespan execution is very slow. (and seems to by interpreting the script far less optimal than Rhino)
>
> Can anyone give me insight in what is happening and where/how to seek improvements?
>
> Regards,
> Roland



More information about the nashorn-dev mailing list