-
Notifications
You must be signed in to change notification settings - Fork 60
How to use sjsonnet as a library with cached parsings? #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@artpaym You can take a look at the usage of If @stephenamar-db thinks a sjsonnet4j module is ok, I can contribute that. @artpaym So you need to create an interpreter with the |
I'm pretty sure the parsing phase is the fast part. The evaluation and materialization are where things get slow |
That's true, @artpaym. You can take a look at the code inside |
Maybe "parsing" isn't a correct term. I don't know all the details of sjsonnet. In other words, for example, if some file takes 100ms to process (with native sjsonnet, for example), is there anything I can do when using an embedded sjsonnet to speed it up? What speed up percentage approximately I could expect? I'm asking because afaik I noticed in jrsonnet the |
You can call jrsonnet as many times as you want, but you need to evaluate jsonnet file once per thread before you start calling functions from it. You are talking about partial evaluation, where your code is being parsed into Then you want to apply (call) this function multiple times with different arguments, and pass resulting |
@artpaym the needed modification is done in sjsonnet, we are using it in Spring Java app. Jrsonnet is fast too. |
@artpaym You need to create the interpreter every time, and because you are passing
But it's the evaluation which is slow. |
Uh oh!
There was an error while loading. Please reload this page.
Is it possible with sjsonnet to parse source jsonnet files once, and then only trigger evaluations providing different input arguments?
If yes, how?
Readme mentions some possibility around it but I can't understand how to make it work, especially from Java. From readme I've seen the following call example, but as I understand it would parse jsonnet file every time whenever I make this call, and
new DefaultParseCache
expression kind of hints that also:Assumption is that it would be much more faster than doing full call every time, because I feel the parsing steps takes the most time. Use case - a Java web app triggering the same mappings (the same file) on each HTTP request just with different arguments.
Would be nice if an answer to that ticket could also result into corresponding readme update.
The text was updated successfully, but these errors were encountered: