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#1370] DMN: refactor BaseFEELFunction getCandidateMethod #6023

Merged
merged 17 commits into from
Jul 17, 2024

Conversation

gitgabrio
Copy link
Contributor

Fixes apache/incubator-kie-issues#1370

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

@gitgabrio gitgabrio requested review from baldimir and yesamer July 11, 2024 15:57
@yesamer
Copy link
Contributor

yesamer commented Jul 12, 2024

TCK tests passed successfully, well done!

@gitgabrio gitgabrio requested a review from mariofusco July 15, 2024 15:10
@yesamer yesamer added the DMN label Jul 15, 2024
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* <p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops

if ( isNamedParams ) {
params = rearrangeParameters(params, this.getParameters().get(0).stream().map(Param::getName).collect(Collectors.toList()));
if (isNamedParams) {
// This is inherently frail because it expects that, if, the first parameter is NamedParameter
Copy link
Contributor

Choose a reason for hiding this comment

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

I think as far as I understand it, this is by the specification. Please see section 10.3.1.2 Grammar rules, Rule 39 in the specification. The "parameters" are either "named parameters" or "positional parameters".

Object[] toReturn = addCtxParamIfRequired(ctx, params, isNamedParams, m);
Class<?>[] parameterTypes = m.getParameterTypes();
if (isNamedParams) {
// This is inherently frail because it expects that, if, the first parameter is NamedParameter and the
Copy link
Contributor

Choose a reason for hiding this comment

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

I think as far as I understand it, this is by the specification. Please see section 10.3.1.2 Grammar rules, Rule 39 in the specification. The "parameters" are either "named parameters" or "positional parameters".

@baldimir
Copy link
Contributor

Do we know the performance impact of this please?

@gitgabrio
Copy link
Contributor Author

@baldimir @yesamer I'm running benchmarks locally, and will share results

@gitgabrio
Copy link
Contributor Author

java -jar target/drools-benchmarks.jar -jvmArgs "-Xms24g -Xmx24g" -foe true -rf csv -rff org.drools.benchmarks.dmn.runtime.*

Main

"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit","Param: numberOfDecisionTableRules","Param: numberOfDecisions","Param: numberOfDecisionsWithBKM","Param: numberOfDecisionsWithContext","Param: numberOfElements","Param: resourceName","Param: sparseness"
"org.drools.benchmarks.dmn.runtime.DMNEvaluateBKModelBenchmark.evaluateBusinessKnowledgeModel","ss",1,250,"136,228013","1,597879","ms/op",,,1000,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateContextBenchmark.evaluateContext","ss",1,250,"84,926047","1,215259","ms/op",,,,1000,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionBenchmark.evaluateDecision","ss",1,250,"18,390020","0,327878","ms/op",,1000,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTableBenchmark.evaluateDecisionTable","ss",1,25000,"0,124058","0,000237","ms/op",1000,,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTablesSparseBenchmark.evaluateDecision","ss",1,250,"71,730503","0,459517","ms/op",,,,,500,,1
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTablesSparseBenchmark.evaluateDecision","ss",1,250,"55,050114","9,043244","ms/op",,,,,500,,2
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTablesSparseBenchmark.evaluateDecision","ss",1,250,"103,669073","12,699690","ms/op",,,,,500,,50
"org.drools.benchmarks.dmn.runtime.DMNEvaluateFewLiteralDecisionBenchmark.evaluateDecision","ss",1,10000,"0,023886","0,000247","ms/op",,20,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateFewLiteralDecisionBenchmark.evaluateDecision","ss",1,10000,"0,070243","0,000334","ms/op",,50,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateFewLiteralDecisionBenchmark.evaluateDecision","ss",1,10000,"0,176526","0,002755","ms/op",,100,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluatePojoInputBenchmark.evaluateModel","ss",1,50000,"0,003180","0,000038","ms/op",,,,,,dmn/pojo-input.dmn,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateTriangularNumHardBenchmark.evaluateContext","ss",1,50000,"0,017950","0,000566","ms/op",,,,20,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateTriangularNumHardBenchmark.evaluateContext","ss",1,50000,"0,069665","0,000491","ms/op",,,,50,,,

1370

"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit","Param: numberOfDecisionTableRules","Param: numberOfDecisions","Param: numberOfDecisionsWithBKM","Param: numberOfDecisionsWithContext","Param: numberOfElements","Param: resourceName","Param: sparseness"
"org.drools.benchmarks.dmn.runtime.DMNEvaluateBKModelBenchmark.evaluateBusinessKnowledgeModel","ss",1,250,"148,923880","1,869031","ms/op",,,1000,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateContextBenchmark.evaluateContext","ss",1,250,"94,991939","1,210490","ms/op",,,,1000,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionBenchmark.evaluateDecision","ss",1,250,"18,946287","0,469829","ms/op",,1000,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTableBenchmark.evaluateDecisionTable","ss",1,25000,"0,136770","0,000359","ms/op",1000,,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTablesSparseBenchmark.evaluateDecision","ss",1,250,"76,335248","0,499248","ms/op",,,,,500,,1
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTablesSparseBenchmark.evaluateDecision","ss",1,250,"64,766308","9,341201","ms/op",,,,,500,,2
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTablesSparseBenchmark.evaluateDecision","ss",1,250,"122,809640","14,658509","ms/op",,,,,500,,50
"org.drools.benchmarks.dmn.runtime.DMNEvaluateFewLiteralDecisionBenchmark.evaluateDecision","ss",1,10000,"0,023541","0,000263","ms/op",,20,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateFewLiteralDecisionBenchmark.evaluateDecision","ss",1,10000,"0,077239","0,000869","ms/op",,50,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateFewLiteralDecisionBenchmark.evaluateDecision","ss",1,10000,"0,187419","0,003048","ms/op",,100,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluatePojoInputBenchmark.evaluateModel","ss",1,50000,"0,006182","0,000214","ms/op",,,,,,dmn/pojo-input.dmn,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateTriangularNumHardBenchmark.evaluateContext","ss",1,50000,"0,018876","0,000579","ms/op",,,,20,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateTriangularNumHardBenchmark.evaluateContext","ss",1,50000,"0,073788","0,000229","ms/op",,,,50,,,

@gitgabrio
Copy link
Contributor Author

@baldimir @yesamer @mariofusco
After some refactoring, thanks also to Mario:

1370

"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit","Param: numberOfDecisionTableRules","Param: numberOfDecisions","Param: numberOfDecisionsWithBKM","Param: numberOfDecisionsWithContext","Param: numberOfElements","Param: resourceName","Param: sparseness"
"org.drools.benchmarks.dmn.runtime.DMNEvaluateBKModelBenchmark.evaluateBusinessKnowledgeModel","ss",1,250,"136,697706","1,151055","ms/op",,,1000,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateContextBenchmark.evaluateContext","ss",1,250,"85,516083","1,346858","ms/op",,,,1000,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionBenchmark.evaluateDecision","ss",1,250,"19,998692","0,196069","ms/op",,1000,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTableBenchmark.evaluateDecisionTable","ss",1,25000,"0,123991","0,000460","ms/op",1000,,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTablesSparseBenchmark.evaluateDecision","ss",1,250,"72,630246","0,546937","ms/op",,,,,500,,1
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTablesSparseBenchmark.evaluateDecision","ss",1,250,"58,596853","9,013453","ms/op",,,,,500,,2
"org.drools.benchmarks.dmn.runtime.DMNEvaluateDecisionTablesSparseBenchmark.evaluateDecision","ss",1,250,"118,861707","15,747500","ms/op",,,,,500,,50
"org.drools.benchmarks.dmn.runtime.DMNEvaluateFewLiteralDecisionBenchmark.evaluateDecision","ss",1,10000,"0,021810","0,000255","ms/op",,20,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateFewLiteralDecisionBenchmark.evaluateDecision","ss",1,10000,"0,069784","0,000498","ms/op",,50,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateFewLiteralDecisionBenchmark.evaluateDecision","ss",1,10000,"0,180393","0,002590","ms/op",,100,,,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluatePojoInputBenchmark.evaluateModel","ss",1,50000,"0,003148","0,000035","ms/op",,,,,,dmn/pojo-input.dmn,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateTriangularNumHardBenchmark.evaluateContext","ss",1,50000,"0,017395","0,000495","ms/op",,,,20,,,
"org.drools.benchmarks.dmn.runtime.DMNEvaluateTriangularNumHardBenchmark.evaluateContext","ss",1,50000,"0,070450","0,000369","ms/op",,,,50,,,

Now the differences seems more negligible and, in few cases, it seems new code is faster

@gitgabrio gitgabrio merged commit fbb6c4c into apache:main Jul 17, 2024
10 checks passed
@gitgabrio gitgabrio deleted the incubator-kie-issues#1370 branch July 17, 2024 07:52
rgdoliveira pushed a commit to rgdoliveira/drools that referenced this pull request Jul 17, 2024
…teMethod (apache#6023)

* [incubator-kie-issues#1370] Clean up signature/unused code

* [incubator-kie-issues#1370] WIP. Implemented first unit test

* [incubator-kie-issues#1370] WIP. Implemented unit tests

* [incubator-kie-issues#1370] WIP. Further refactoring with unit tests. Fully working

* [incubator-kie-issues#1370] WIP. Begin ScorerHelper implementation. Fully working

* [incubator-kie-issues#1370] WIP. Implemented ScorerHelper with test. Fully working

* [incubator-kie-issues#1370] WIP. TODO: fix score logic - corner cases not covered. Issues with singleton list of null element

* [incubator-kie-issues#1370] Working. Implemented tests.

* [incubator-kie-issues#1370] Fully working. Fixing corner cases with Object parameters

* [incubator-kie-issues#1370] Implemented CustomFunction invocation test

* [incubator-kie-issues#1370] Improvement based on PR suggestion

* [incubator-kie-issues#1370] Fix formatting

* [incubator-kie-issues#1370] Benchmark improving - refactoring

---------

Co-authored-by: Gabriele-Cardosi <[email protected]>
rodrigonull pushed a commit to rodrigonull/incubator-kie-drools that referenced this pull request Oct 7, 2024
…teMethod (apache#6023)

* [incubator-kie-issues#1370] Clean up signature/unused code

* [incubator-kie-issues#1370] WIP. Implemented first unit test

* [incubator-kie-issues#1370] WIP. Implemented unit tests

* [incubator-kie-issues#1370] WIP. Further refactoring with unit tests. Fully working

* [incubator-kie-issues#1370] WIP. Begin ScorerHelper implementation. Fully working

* [incubator-kie-issues#1370] WIP. Implemented ScorerHelper with test. Fully working

* [incubator-kie-issues#1370] WIP. TODO: fix score logic - corner cases not covered. Issues with singleton list of null element

* [incubator-kie-issues#1370] Working. Implemented tests.

* [incubator-kie-issues#1370] Fully working. Fixing corner cases with Object parameters

* [incubator-kie-issues#1370] Implemented CustomFunction invocation test

* [incubator-kie-issues#1370] Improvement based on PR suggestion

* [incubator-kie-issues#1370] Fix formatting

* [incubator-kie-issues#1370] Benchmark improving - refactoring

---------

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: refactor BaseFEELFunction getCandidateMethod
4 participants