schibsted / jslt

JSON query and transformation language
Apache License 2.0
633 stars 119 forks source link

Support for compiled JSLT template. #1

Open pratikpparikh opened 6 years ago

pratikpparikh commented 6 years ago

Dear Author,

Could you please look at the possibility of implementing a compiled templates?

Regards, Pratik Parikh

larsga commented 6 years ago

The templates are compiled. When you call Parser.compileString what you get back is a template that's fully parsed and ready to be executed. It's even been through an optimizer. So in that sense it's compiled.

If you mean compiled to Java bytecode I have experimented with that, and found a 15-20% speedup. So the gains are not that large, at least not without additional tricks. It's not part of the current code, but it's something I intend to work on in the future.

Does that answer your question?

pratikpparikh commented 6 years ago

@larsga yes I meant for compiled to Java bytecode and it would be great to have 15-20% speedup.

larsga commented 6 years ago

I will work on that, but it's a lot of work, and I think you'll find performance is pretty good already. I can run a large, complex transform at 150,000 transforms/second in a single thread on my laptop.

I will probably give priority to more work on the optimizer before I start working on bytecode compilation again, because there is some low-hanging fruit there. Having the optimizer handle those cases will benefit generated bytecode as well.

pratikpparikh commented 6 years ago

@larsga, I just thought about this as a feature (because XSLT and other transformation libraries have benefited from it in the past) but I agree other optimizations are more important.

larsga commented 6 years ago

I agree, and I'm still planning to do it. But it will take a while.