Skip to content
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

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

Merged
merged 25 commits into from
Jun 24, 2024

Conversation

gitgabrio
Copy link
Contributor

@gitgabrio gitgabrio commented Jun 3, 2024

Fixes apache/incubator-kie-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 to handle cross repository builds and be sure that we always use latest version of the code for each repository.

build-chain tool 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 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

Gabriele-Cardosi added 14 commits May 27, 2024 15:11
… Visitor signatures. Reordered Visitor methods
…roved codegen - singleton BASENODE instantiation
…roved codegen - singleton UNARY_TESTS instantiation
@gitgabrio
Copy link
Contributor Author

gitgabrio commented Jun 5, 2024

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
Copy link
Contributor Author

gitgabrio commented Jun 5, 2024

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"

@gitgabrio gitgabrio marked this pull request as ready for review June 13, 2024 12:00
@yesamer yesamer added the DMN label Jun 18, 2024
Copy link
Contributor

@yesamer yesamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review (part 1)

@gitgabrio gitgabrio merged commit cf4ef68 into apache:main Jun 24, 2024
10 checks passed
@gitgabrio gitgabrio deleted the incubator-kie-issues#1206 branch June 24, 2024 11:50
rgdoliveira pushed a commit to rgdoliveira/drools that referenced this pull request Jul 8, 2024
…de gen execution (apache#5978)

* [incubator-kie-issues#1206_reimplement_visitor] Refactored BaseNode and Visitor signatures

* [incubator-kie-issues#1206_reimplement_visitor] Restored BaseNode and Visitor signatures. Reordered Visitor methods

* [incubator-kie-issues#1206_reimplement_visitor] WIP - broken

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] WIP - All node implemented. Broken

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] WIP - All node implemented. Broken

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] WIP - fixing tests

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] WIP - fixed FEELDateTimeDurationTest

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] WIP - fixed FEELStringOperationsTest

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] WIP - fixed FEELStaticTypeTest

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] WIP - fixed feel tests

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] Fixed alphanetwork support. ALl tests works

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] Improved codegen - singleton BASENODE instantiation

* [incubator-kie-issues#1206_reimplement_visitor_new_node_approach] Improved codegen - singleton UNARY_TESTS instantiation

* [incubator-kie-issues#1206] Restore log config

* [incubator-kie-issues#1206] Removing unused methods/classes

* [incubator-kie-issues#1206] Further cleanup/reorganization

* [incubator-kie-issues#1206] Managing AliasFEELType

* [incubator-kie-issues#1206] Managing AliasFEELType

* [incubator-kie-issues#1206] Removing duplication of same nodes in codegen

* [incubator-kie-issues#1206] Cleanup

* [incubator-kie-issues#1206] Removed unused class

* [incubator-kie-issues#1206] Fix as per PR request

* [incubator-kie-issues#1206] Small refactoring/improvement

---------

Co-authored-by: Gabriele-Cardosi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DMN - Remove code path duplication for code gen execution
3 participants