graaljs
graaljs copied to clipboard
Caching compiled JS script
I am writing a macro assembler in Java. Macros can be written by the user in javascript. When assembling hundreds files using one JS engine and one context per thread (I use multithreading) performance (per file) is impressive.
However when assembling one file, it really takes too much time, since all macros used must be recombiled by GraamVM every time.
I am writing a script cache server so that the compiled code of a JS macro used in a previous run and that was not change in the meantime , can be retrieved and reused during successive runs.
To do this I need access to the compiled JS code in a serializable format so I can cache it using this server. I cannot find any information about such functionality, and I doubt it exists now.
Is there hope it will be available in the future?
Thanks....... Paolo
Hi @PaoloFR
thanks for your question. I assume you are aware about the Source.Builder cached()
function, i.e., that Sources and thus their compilations can be cached across Context. See https://www.graalvm.org/docs/reference-manual/embed/#code-caching-across-multiple-contexts
What you seem to suggest is to write the compilation down to disk, to load it later. That is an interesting idea, that we have started to investigate ourselves. But at the moment, we have no solution in that area.
Best, Christian
Christian:
As you say, saving compiled JS code for later use is exactly what I need. I notice that you have marked it as "enhancement" and you have self assigned yourself to it.
I really look forward to it.
My apologies for sending this comment to you kind of late, but I tried to add a comment to the board and something did not work. When it comes to forum boards, I am kind of retarded....
Thank you and Best Regards....... Paolo
On Thu, Mar 12, 2020 at 8:39 AM Christian Wirth [email protected] wrote:
Hi @PaoloFR https://github.com/PaoloFR
thanks for your question. I assume you are aware about the Source.Builder cached() function, i.e., that Sources and thus their compilations can be cached across Context. See https://www.graalvm.org/docs/reference-manual/embed/#code-caching-across-multiple-contexts
What you seem to suggest is to write the compilation down to disk, to load it later. That is an interesting idea, that we have started to investigate ourselves. But at the moment, we have no solution in that area.
Best, Christian
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/graalvm/graaljs/issues/259#issuecomment-598162969, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBI44XVL45SGW45BVKBC2TRHDJXJANCNFSM4LFLKGKA .
I notice that you have marked it as "enhancement" and you have self assigned yourself to it.
Note that does not mean I am actively working on that, just tracking it from the JavaScript side. We do have experiments in that general area (for Truffle languages in general), I'll update this ticket here if there are news on that.
Best, Christian
Hi Christian,
Is this enhancement still planned? This would be very useful to my team especially if it enabled precompiling at build time to avoid a cold start.
Thanks, David
Hi @davidretler
Yes, this is still being worked on by the GraalVM/Truffle team. As stated above, we will support it as soon as it is available, but I cannot give you an ETA on that. Contact from the Truffle team would be @chumer
Best, Christian
@wirthi I am waiting this... I can't serializable CompiledScript QQ I think if CompiledScript or Context can implements Serializable . we can achieve CompiledScript or Contextcache...
Hi,
We are working on that feature and I expect there will be some publication on that shortly. You can see some hints in the Truffle Changelog already, note the entry for the upcoming GraalVM 22.1 release on "auxiliary engine caching". Some documentation is already available at https://www.graalvm.org/22.0/graalvm-as-a-platform/language-implementation-framework/AuxiliaryEngineCachingEnterprise/
Note that this will be a standalone feature of GraalVM Enterprise, and unrelated to both javax.script.CompiledScript
and Serializable
.
Best, Christian
that's a bad news... thanks