Asciidoctor.js on Nashorn JDK 9 is considerably slower than Nashorn JDK 8
Marcus Lagergren
marcus.lagergren at oracle.com
Mon Mar 16 12:59:26 UTC 2015
Yes. This probably has to do with optimistic typing being enabled to increase JavaScript runtime performance in 9. We know that 9 is currently slower at startup because we generate more correct code (and throw away too optimistic code that we generate first).
Try running with —optimistic-types=false and see if you get back to 8-like performance and startup.
We have plans to cheapen startup time considerably until 9 FC.
You can also try using the code caching feature from 8u40:
https://blogs.oracle.com/nashorn/entry/improving_nashorn_startup_time_using
Regards
Marcus
> On 03 Jan 2015, at 21:01, Guillaume Grossetie <grossetieg at gmail.com> wrote:
>
> Hello everyone and happy new year!
>
> Asciidoctor.js is now running on both JDK 8b19 (build 25.40-b23) and JDK
> 9b44 (build 1.9.0-ea-b44).
> We noticed that JDK 9 is considerably slower than JDK 8 Nashorn but at the
> same time running "basic" Javascript seems faster on JDK 9.
>
> We have a simple Rake task[1] that execute the same examples with the
> latest JDK 8 and JDK 9:
>
> *Result with JDK 8:*
>
> Running Nashorn jjs spec/share/basic.js... OK in *909.052 ms*
> Running Nashorn jjs spec/share/asciidoctor-convert.js... OK in *9335.534 ms*
> Running Nashorn java BasicJavascriptWithNashorn... OK in *927.053 ms*
> Running Nashorn java AsciidoctorConvertWithNashorn... OK in *8843.506 ms*
>
> So less than a second for basic Javascript and around 10 seconds to convert
> AsciiDoc source to HTML5.
>
> *Result with JDK 9:*
>
> Running Nashorn jjs spec/share/basic.js... OK in *860.049 ms*
> Running Nashorn jjs spec/share/asciidoctor-convert.js... OK in *31253.788
> ms*
> Running Nashorn java BasicJavascriptWithNashorn... OK in *833.048 ms*
> Running Nashorn java AsciidoctorConvertWithNashorn... OK in *30584.749 ms*
>
> As you can see basic.js runs a little faster but asciidoctor-convert.js is
> considerably slower (three times slower ~30 seconds).
>
> The basic.js[2], asciidoctor-convert.js[3] and asciidoctor-all.js[4] are
> available on GitHub.
> Asciidoctor.js is generated from Ruby using Opal[5] as a result the
> file asciidoctor-all.js
> is not easy to read but the entry point is the method $convert[6].
>
> Let me know if you need more information.
>
> Cheers,
> Guillaume
>
> [1] https://github.com/asciidoctor/asciidoctor.js/blob/master/Rakefile#L105
> [2]
> https://github.com/asciidoctor/asciidoctor.js/blob/master/spec/share/basic.js
> [3]
> https://github.com/asciidoctor/asciidoctor.js/blob/master/spec/share/asciidoctor-convert.js
> [4]
> https://github.com/asciidoctor/asciidoctor.js/blob/master/dist/asciidoctor-all.js
> [5] http://opalrb.org/
> [6]
> https://github.com/asciidoctor/asciidoctor.js/blob/master/dist/asciidoctor-all.js#L24419
More information about the nashorn-dev
mailing list