Performance impact of drools language vs java

2,543 views
Skip to first unread message

ian.chen...@gmail.com

unread,
Jan 19, 2017, 7:02:35 PM1/19/17
to Drools Usage

Hi,

 

I am curious to learn about the performance difference between rules written in drools language vs custom static method written in Java.

 

My project uses an object manager written in Java and we have been relying heavily on eval and java functions. As a result, the rete tree generated for the rules have less layers.

 

My general understanding is that rules written in drools language optimizes for resource usage while java implementation optimizes for performance. Is this correct?

 

Also, is there any performance difference between java and mvel dialect, or is the difference purely syntactic? What is the intended use of mvel vs. java or vice-versa?

 

Thanks

 

Ian

Edson Tirelli

unread,
Jan 22, 2017, 11:14:39 AM1/22/17
to drools...@googlegroups.com

  It is hard to talk specifics without details about the use case, but the general idea is that the more rules and the more complex the rules are, the more benefits the rules engine will give you. In other words, if you have a dozen rules and you concern is performance, then static java code will be better. But as the number of rules increase to several dozen, hundreds and thousands, then the rules engine will be faster than static methods in java by orders of magnitude.

  This happens because increasing the number of rules has usually little to negligible impact on the response time (it has O(1) scalability for increasing number of rules). In other words, a rulebase with 1000 rules will typically give you the same average response time as a rule base with 10000 rules. I will not go into details about why, but there are lots of papers out there that explain it. 

My general understanding is that rules written in drools language optimizes for resource usage while java implementation optimizes for performance. Is this correct?

  No, it is the other way around. Rule engines usually trade memory usage for performance, so the same set of rules written in java will typically use less memory to be executed, but also will be slower (again, talking about use cases with hundreds+ rules). 

  Drools has been benchmarked on use cases handling millions of transactions per second on hundreds of thousands of rules (yes, not a typo, those are actual numbers) and it required just a fraction of the number of cores required to process the same rules with the same throughput as using other Java and C++ implementations. Again, the larger the use case, larger the gains.

Also, is there any performance difference between java and mvel dialect, or is the difference purely syntactic? What is the intended use of mvel vs. java or vice-versa?

   
  In version 6+, the performance difference between the MVEL and the Java dialect is negligible after warm up. For this reason, in version 6+, the LHS of the rules always uses MVEL. You can only select the dialect for the RHS of the rules.

  Edson





--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/67c913f5-512a-411c-9b49-06df7be6cb65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
  Edson Tirelli
  Sr Principal Software Engineer 
  Red Hat Business Systems and Intelligence Group

Reply all
Reply to author
Forward
0 new messages