How to improve drools performance?
Is there a way to log / monitor the time taken for rule in a Drools rule 开发者_如何转开发set?
Is there a way to make sure that one rule is not executed more than once(It seems to be happening in my case)
What are the general guidelines on improving Drools performance?
Currently I am using a one single DRL file with 100 odd rules.
Any additiional information you need will be provided.
If your goal is to log/monitor rules execution, you can use either the Event Listeners, like AgendaEventListener (http://docs.jboss.org/drools/release/5.3.0.CR1/drools-expert-docs/html_single/index.html#d0e2003) or activate Drools MBeans to monitor a Drools application using any JMX console of your choice. MBeans will give you per rule stats and summarized stats.
How to improve performance is a very broad question and the answer would be much longer than I can answer here, but the short version is: a rules engine like Drools is a relational engine similar to relational databases, but with different goals and optimizations. Nevertheless, many of the same principles apply, and you can improve performance by writing rules with tighter constraints first, sharing constraints among multiple rules and making proper use of inference/chaining.
Just FYI, if you are in the San Francisco area, we will have a free Drools bootcamp (but you still have to register) next week during the Rules Fest (http://rulesfest.org/html/home.html) where we will present many of related topics.
The only pitfall I found fundamental while working with drools is about when block authoring. Don't use computations in when blocks. This is what drools says even about getters!:
Person( age == 50 )
// this is the same as:
Person( getAge() == 50 )
Note
We recommend using property access (age) over using getters explicitly (getAge()) because of performance enhancements through field indexing. (source)
Droolsassert testing library can help you detect rules which are triggered more than once and log/monitor time taken by each rule.
精彩评论