Performance evaluating decisions with input expression scripts

Hi,

a standalone DMN engine is a great tool for handling complex configuration scenarios.
Only the performance seems to be a problem if I have to use a ScriptEngine (i.e. method invocations and usage of constants).

The same decision with a single input ("variable * 100") in the Input Expression, has massively differing evaluation times:

  1. If the input expression is evaluated via JUEL (by default), or
  • if the same input expression is evaluated via JavaScript (Nashorn in Java 8).

The difference is a factor of ~10-20 (i.e. it takes JS 10ms instead of JUEL’s 0.5ms for a decision table with a single input). Main reason is the ScriptEngineManager in the DefaultScriptEngineResolver, which is creating a new JS engine instance for each execution (from the registered engine factory).

What are the reasons for not reusing those engine instances?
My rudimentary tests with a custom ScriptEngineResolver indicate that the performance deficit could be cut down by half by reusing the same instance for multiple executions…

Are there other possibilities to tweak the performance of Input Expression scripts?

Or how can I do something like com.sample.MathUtils.convert(variable.property, com.sample.TypeEnum.VALUE) with JUEL?

Hi Carsten,

sorry for the late response. You observations are correct. Currently the script engines are not cached by the standalone DMN engine.

The reason is mainly that it wasn’t implemented yet. And that we had several issues with caching of script engines in the process engine in combination with process applications. Feel free to submit a pull request if you already implemented something. It would be great to have this improvement.

There are currently no efforts to improve the performance of the DMN engine. Nevertheless if you have any ideas regarding improvements please share them.

It is possible to register custom functions in the JUEL engine. For that you have to register a new function mapper in the ElContextFactory similar to our FEEL implementation. To use it in the DMN engine you can configure a own JuelElProvider.

Cheers,
Sebastian