apache / incubator-kie-drools

Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.
http://www.drools.org
5.85k stars 2.49k forks source link

[incubator-kie-issues#1206] DMN - Remove code path duplication for code gen execution #5978

Closed gitgabrio closed 3 months ago

gitgabrio commented 4 months ago

Fixes https://github.com/apache/incubator-kie-issues/issues/1206

This PR

  1. add BaseNode constructors to be instantiated with values from original ones
  2. refactor DMN code-gen so thatn newly instantiadet BaseNOdes would be used instead of custom code
  3. features some singleton pattern in generated code to avoid re-instantiation of same object

Side-note: still WIP - lot of cleanup and verification needed, but wanted to start discussing the approach

How to replicate CI configuration locally? Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use [build-chain tool](https://github.com/kiegroup/github-action-build-chain) to handle cross repository builds and be sure that we always use latest version of the code for each repository. [build-chain tool](https://github.com/kiegroup/github-action-build-chain) is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See [local execution](https://github.com/kiegroup/github-action-build-chain#local-execution) details to get more information about it.
How to retest this PR or trigger a specific build: - for pull request and downstream checks - Push a new commit to the PR. An empty commit would be enough. - for a full downstream build - for github actions job: add the label `run_fdb` - for Jenkins PR check only - If you are an ASF committer for KIE podling, login to Jenkins (https://ci-builds.apache.org/job/KIE/job/drools/), go to the specific PR job, and click on `Build Now` button.
gitgabrio commented 4 months ago

Preliminary benchmark comparison of org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark

main branch

"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit","Param: expression"
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledButInterpretedExpression","avgt",1,100,"0,042272","0,001634","us/op","if 2 > 1 then ""yey"" else ""nay"""
org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledButInterpretedExpression,"avgt",1,100,"0,040522","0,000181","us/op","if 2 < 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledButInterpretedExpression","avgt",1,100,"0,681583","0,006947","us/op","for x in [ 10, 20, 30 ], y in [ 1, 2, 3 ] return ""foobar"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledJavaExpressionBenchmark","avgt",1,100,"0,041961","0,001515","us/op","if 2 > 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledJavaExpressionBenchmark","avgt",1,100,"0,040979","0,000645","us/op","if 2 < 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledJavaExpressionBenchmark","avgt",1,100,"0,665966","0,009778","us/op","for x in [ 10, 20, 30 ], y in [ 1, 2, 3 ] return ""foobar"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateExpressionBenchmark","avgt",1,100,"10,106472","0,177177","us/op","if 2 > 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateExpressionBenchmark","avgt",1,100,"10,900692","0,680559","us/op","if 2 < 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateExpressionBenchmark","avgt",1,100,"18,890975","0,305276","us/op","for x in [ 10, 20, 30 ], y in [ 1, 2, 3 ] return ""foobar"""

comparison commit

"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit","Param: expression"
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledButInterpretedExpression","avgt",1,100,"0,043069","0,001292","us/op","if 2 > 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledButInterpretedExpression","avgt",1,100,"0,039671","0,000350","us/op","if 2 < 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledButInterpretedExpression","avgt",1,100,"0,671387","0,006671","us/op","for x in [ 10, 20, 30 ], y in [ 1, 2, 3 ] return ""foobar"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledJavaExpressionBenchmark","avgt",1,100,"0,041239","0,000543","us/op","if 2 > 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledJavaExpressionBenchmark","avgt",1,100,"0,047702","0,001352","us/op","if 2 < 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateCompiledJavaExpressionBenchmark","avgt",1,100,"0,672820","0,004684","us/op","for x in [ 10, 20, 30 ], y in [ 1, 2, 3 ] return ""foobar"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateExpressionBenchmark","avgt",1,100,"10,056198","0,116080","us/op","if 2 > 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateExpressionBenchmark","avgt",1,100,"10,045815","0,126247","us/op","if 2 < 1 then ""yey"" else ""nay"""
"org.drools.benchmarks.dmn.feel.FEELConditionAndLoopBenchmark.evaluateExpressionBenchmark","avgt",1,100,"19,195948","0,676614","us/op","for x in [ 10, 20, 30 ], y in [ 1, 2, 3 ] return ""foobar"""
gitgabrio commented 3 months ago

Preliminary benchmark comparison of org.drools.benchmarks.dmn.codegen.*

main branch

"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit"
"org.drools.benchmarks.dmn.codegen.ImportedModelCodegenBenchmark.evaluateModelBenchmark","avgt",1,100,"25,224975","0,730852","us/op"
"org.drools.benchmarks.dmn.codegen.PrequalificationCodegenBenchmark.evaluateModelBenchmark","avgt",1,100,"58,649328","1,372456","us/op"

comparison commit

"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit"
"org.drools.benchmarks.dmn.codegen.ImportedModelCodegenBenchmark.evaluateModelBenchmark","avgt",1,100,"24,608531","0,611788","us/op"
"org.drools.benchmarks.dmn.codegen.PrequalificationCodegenBenchmark.evaluateModelBenchmark","avgt",1,100,"57,529849","0,939727","us/op"