Hi Kunal,

I'm currently loking at the benchmark scripts you posted.

One approach you should try is to use a single Nashorn ScriptEngine with multiple bindings (i.e. JS global objects). This allows Nashorn to share compiled classes among multiple threads. It's probably the best improvement you can make to startup and warmup time if you're using multiple JS environments on multiple threads. On the other hand, it may reduce top performance a little bit because of added polymorphism.

I've written about this in my recent Nashorn blog post, it also contains demo code for how to set up the script engine for multiple threads:

https://blogs.oracle.com/nashorn/entry/improving_nashorn_startup_time_using

I hope this helps. I'll get back to you when I'm done trying your scripts.

Hannes

Am 2015-03-11 um 02:52 schrieb Kunal Cholera:
Hello Nahsorn dev team,

Currently our warmup strategy does the following - before our application 
starts serving request to real users we create 24 Nashorn instances. We are 
limiting to 24 as we have 24 CPU cores per machine in production. We then load 
the javascript files into this nashorn instances to setup the context for 
javascript execution. We then execute each of these javascript 2000 times with 
mock data to warmup the execution times.

We have observed it takes about 4000 iterations[1] to reach optimal 
performance. See the graph here that shows 4000 javascript executions on 1 
javascript file -
https://drive.google.com/file/d/0B5PpdCJ7YycqbDJBWGRRVjRsYVU/view?usp=sharing

Three questions
1.What is the best way to quickly warm-up to reach optimal performance in fewer 
iterations ?

2. Is there a better way to warmup using fixture data as opposed to fake data 
which we have to maintain ?

3. Is there a way to clone 1 nashorn instances that is warmed up so that we can 
avoid doing the same warmup for other nashorn instances ?

[1]
Steps to reproduce these performance numbers -
Download this 
ziphttps://drive.google.com/file/d/0B5PpdCJ7YycqMWlVQ0FsNlozcTA/view?usp=sharing
 which has the following four files
1. bench.js - the benchmarking script
2. hp.js - the javascript we want to execute on Nashorn
3. hp.json - the data we want to use while executing our script hp.js
4. dust-full.js - library needed to execute hp.js script

I am using "1.8.0_40-ea" Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b25 
on 8 core redhat linux machine ).

Please advise.

Thanks
Kunal Cholera

Reply via email to