jmreardon-yoppworks opened a new issue, #875: URL: https://github.com/apache/incubator-kie-issues/issues/875
I am observing poor performance when using FEEL filter expressions that have BKM invocations or function calls (eg. someList[ends with(itemType, "_TEST")]). Profiling shows that most of the run time is spent constructing stack traces for an exception created in PropertyValueResult.notDefined()([here](https://github.com/kiegroup/drools/blob/ffb40c47b1ae64678525799e60186017b7d4a5eb/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java#L293)) as the FEEL evaluator tries to resolve the names in the expressions. # Benchmarks I have some benchmarks (in Scala, sorry) & DMN demonstrating the behavior in this repository: https://github.com/jmreardon-yoppworks/dmn-bench. Results from running locally are as follows: ``` [info] Benchmark Mode Cnt Score Error Units [info] DmnListFilterBench.evaluate1Function thrpt 10 15.985 ± 0.441 ops/ms [info] DmnListFilterBench.evaluate2Functions thrpt 10 8.790 ± 0.189 ops/ms [info] DmnListFilterBench.evaluateBool thrpt 10 127.600 ± 1.373 ops/ms [info] DmnListFilterBench.evaluateBoolItem thrpt 10 10.472 ± 0.192 ops/ms ``` Each test evaluates a single decision that counts the number of elements in a filtered list of contexts containing 2 fields, using the following FEEL expressions: | Function | FEEL Expression | | --- | --- | | evaluate1Function|`count(reports[ends with(value, "1")])` | | evaluate2Functions|`count(reports[ends with(value, "1") or starts with(value, "2")])` | | evaluateBoolItem|`count(reports[item.value = "11"])` | | evaluateBoolItem|`count(reports[value = "11"])` | # Analysis Using any name in these expression other than names in the context causes a major performance hit. Profiling these benchmarks with JFR shows the vast majority of the runtime within `PropertyValueResult.notDefined()` generating the stack trace for the exception it creates. JFR data recorded while running evaluate1Function: [ForkedMain_2024_01_31_175636.jfr.zip](https://github.com/apache/incubator-kie-issues/files/14118250/ForkedMain_2024_01_31_175636.jfr.zip) # Fixing I attempted to fix this locally setting the result in `notDefined()` to `null` instead of an exception. This does not have any semantic change in any uses in Drools and dramatically improves the outcomes: ``` [info] Benchmark Mode Cnt Score Error Units [info] DmnListFilterBench.evaluate1Function thrpt 10 66.537 ± 2.870 ops/ms [info] DmnListFilterBench.evaluate2Functions thrpt 10 46.667 ± 1.106 ops/ms [info] DmnListFilterBench.evaluateBool thrpt 10 128.376 ± 3.873 ops/ms [info] DmnListFilterBench.evaluateBoolItem thrpt 10 108.519 ± 2.903 ops/ms ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
