Questions about how to use persistent code cache correctly in JDK-8u40

Kunal Cholera kcholera at
Wed Mar 11 01:32:01 UTC 2015

Hello Nahsorn dev team,

Currently I am using -pcc flag using this command “jjs bench.js -scripting -pcc=true -- 10000” [1] to use the persistent code cache feature. Across different runs using jjs I see the first few javascript executions always take very long. For e.g. the first run execution times(ms) were “993,149,141,121,102,94,101,86,80...”, second run execution times (ms) were “796,148,137,135,107,102,96,95,95...”. I was expecting the second run would be much faster and start off at <100ms since the nashorn_code_cache already existed from the first run. Raw data - (see column with pcc=true for persistent code cache data)

I have three questions around persistent code cache usage -

1. Am I using the persistent code cache feature correctly by just specifying the -pcc=true parameter ?

2. Can these compiled scripts under nashorn_code_cache be used across different machines or different nashorn instances on the same machine? if so how can we specify to Nashorn to reuse an existing code cache folder when it starts up? There is a flag -Dnashorn.persistent.code.cache to specify where the code cache should be generated, but I could not find a way to specify to Nashorn where to pick up existing code cache.

3. Does the compiled code change after many executions because of any optimization? If so how can we reuse this compiled code cache across different machines ?

Steps to reproduce these performance numbers -
Download this zip 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.

Kunal Cholera

More information about the nashorn-dev mailing list