RFR: JDK-8186694: JShell: speed-up compilation by reusing compiler instances
Jan Lahoda
jan.lahoda at oracle.com
Tue Aug 29 19:58:46 UTC 2017
Hello,
When starting jshell like this (where "/tmp/script" is a file which has
just "/exit"):
$ jshell PRINTING --execution local /tmp/script
It currently takes approx. 5-6s on my laptop. PRINTING will add quite a
few startup snippets. Each of these snippets is processed separately and
needs several instances of javac to be created to be processed correctly.
So, the idea in this patch is to reuse the javac instances multiple
(many) times. This avoids initializing the javac instances just to
process a very small ("single line") input.
This patch is based on the ReusableContext by Maurizio used in tests.
The ReusableContext handling is wrapped in JavacTaskPool, which keeps
the ReusableContext and issues JavacTask possibly based on a reused
Context. The pool is not currently general purpose, but should work for
tests for which ReusableContext worked and for JShell.
One tricky thing is that in JShell, it is necessary to prune everything
in the "REPL" package when reusing the Context, as it is necessary to
reload the correct/updated classes again from the file manager (this is
achieved by additional cleaning in TaskFactory).
Overall, with this patch, the time to execute the above command is
approx. 2.5s
Bug:
https://bugs.openjdk.java.net/browse/JDK-8186694
Webrev:
http://cr.openjdk.java.net/~jlahoda/8186694/webrev.00/
How does this look?
Thanks,
Jan
More information about the kulla-dev
mailing list