[jboss-jira] [JBoss JIRA] (DROOLS-1685) Improve performance of rules using "or" in LHS

Mario Fusco (JIRA) issues at jboss.org
Wed Aug 9 09:01:00 EDT 2017


    [ https://issues.jboss.org/browse/DROOLS-1685?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13446324#comment-13446324 ] 

Mario Fusco commented on DROOLS-1685:
-------------------------------------

[~rmorrise] Did you give a try to my suggestion? Did it fix the problem or do you still see the same perf difference? In this second case can you please provide a complete reproducer?

> Improve performance of rules using "or" in LHS
> ----------------------------------------------
>
>                 Key: DROOLS-1685
>                 URL: https://issues.jboss.org/browse/DROOLS-1685
>             Project: Drools
>          Issue Type: Enhancement
>          Components: core engine, kie server
>    Affects Versions: 6.5.0.Final
>            Reporter: Russell Morrisey
>            Assignee: Mario Fusco
>
> The following two rulesets produce the same output, but their performance differs dramatically.
> My understanding is that the two rulesets should be equivalent to one another. It seems like the 'or' operation must be handled inefficiently by the engine. Is there anything that can be improved the engine's performance in this case?
> Ruleset #1 takes ~3 seconds to execute on my local machine (for a dataset with 3 entities, 1 service ordered each). Ruleset #2 runs in ~200 ms.
> *Ruleset 1*
> {code:java}
> rule "Rule183"
> 	dialect "mvel"
> 	when
> 		$entity : Entity( )
> 		( $service : ServiceOrdered( serviceId == "FORM" , entity == $entity , entity.entityTypeId in ( 291262, 291275, 291277 ) ) or $service : ServiceOrdered( serviceId == "DISSO" , entity == $entity , entity.entityTypeId in ( 291262 ) , stateId == 290864 ) )
> 		$r1 : QuestionDefinition( id == 590 )
> 	then
> 		Question fact0 = new Question();
> 		fact0.setQuestionDefinition( $r1 );
> 		fact0.setEntity( $entity );
> 		insert( fact0 );
> end
> {code}
> *Ruleset 2*
> {code:java}
> rule "Rule183"
> 	dialect "mvel"
> 	when
> 		$entity : Entity( )
> 		$service : ServiceOrdered( serviceId == "FORM" , entity == $entity , entity.entityTypeId in ( 291262, 291275, 291277 ) )
> 		$r1 : QuestionDefinition( id == 590 )
> 	then
> 		Question fact0 = new Question();
> 		fact0.setQuestionDefinition( $r1 );
> 		fact0.setEntity( $entity );
> 		insert( fact0 );
> end
> {code}
> {code}
> rule "Rule183-2"
> 	dialect "mvel"
> 	when
> 		$entity : Entity( )
> 		$service : ServiceOrdered( serviceId == "DISSO" , entity == $entity , entity.entityTypeId == 291262 , stateId == 290864 )
> 		$r1 : QuestionDefinition( id == 590 )
> 	then
> 		Question fact0 = new Question();
> 		fact0.setQuestionDefinition( $r1 );
> 		fact0.setEntity( $entity );
> 		insert( fact0 );
> end
> {code}



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list