Hello,
I would like to improve the performance of my
Drools process, I have already done some enhancements like removing the use of “collect”
and “eval”.
I must say I’m a Drools newbie struggling to determine
what causes my performance problems.
Before asking, I need to explain in few words the
problem I want to solve with Drools :
My company is a bank where traders are making deals
on markets, these deals must be classified in book, this is what we call
“booking process”.
Booking is done according to booking criteria : which
trader has made the deal ? on which product ? etc …
A booking rule defines a set of criteria and the
target book where the deal will classified.
I’m using Drools to :
I’m testing the booking process with 1000
deals and 229 booking rule.
It takes 60 seconds for Drools to book the 1000
deals, which is too slow to be put in production.
On the 60 seconds, I have 7 seconds for facts
insertion and the remaining for process (after session.fireAllRules)
Do you think such numbers are normal/expected ?
Like I said I don’t really know where the
performance bottlenecks are … I’m thinking of exploring the
following possibilities :
I have put my rules code below (for courageous people),
if you see some obvious performance problems or if you can give some hint to
explore, you would be very welcome.
Thanks in advance for your lights,
Regards,
Joël Costigliola
Ps : rules details
I have defined a flow composed of 3 steps/rules
group, each group has one rule, here’s the flow and the rules.
Flow :
------
"Find
matching booking rules" -> "Refresh" -> "Apply
booking rule group"
Rules :
------
The job of this rule is to store in DealMatchingBookingRules all
the booking rule matching a specific deal (each DealMatchingBookingRules instance
has a unique Deal).
rule "Find
matching level 1 booking rules by deal"
salience 10
no-loop
ruleflow-group "Find
level 1 matching booking rules by deal group"
when
$dealMatchingBookingRules :
DealMatchingBookingRules($dealModel : deal, $dealProductRelatedIndexes :
dealProductRelatedIndexes)
$bookingRule : BTExecutionBookingRuleModel (
priority == 1
//
when a criterion is not set, it is considered as satisfied.
&& (traderCriterion == null || $dealModel.trader ==
traderCriterion)
&& (portfolioCriterion == null || $dealModel.portfolio ==
portfolioCriterion)
//
when a product type criterion is set to unknown, it is considered as satisfied
whatever deal product type is.
&& (productTypeStringCriterion == null || productTypeCriterion ==
ProductType.Unknown
|| $dealModel.product.productType ==
productTypeCriterion)
&& (listedIndexCriterion == null || $dealProductRelatedIndexes.relatedIndexes
contains listedIndexCriterion)
)
then
Logger log = LoggerFactory.getLogger("Matching booking rules
LOGGER");
log.info("Found a level 1 matching rule for deal : " + $dealModel + ", rule is " + $bookingRule);
$dealMatchingBookingRules.addMatchingBookingRule($bookingRule);
end
// used to tell Drools that our $dealMatchingBookingRules are
ready for next step in flow
rule "Refresh
facts in level 1 booking rule process"
salience 5
no-loop
ruleflow-group "Refresh
facts in level 1 booking rule process group"
when
$dealMatchingBookingRules : DealMatchingBookingRules()
then
update($dealMatchingBookingRules);
end
rule "Apply
level 1 booking rule"
no-loop
ruleflow-group "Apply
level 1 booking rule group"
when
$dealMatchingBookingRules :
DealMatchingBookingRules(hasSingleMatchingLevel1BookingRule == true)
then
BTExecutionBookingRuleModel effectiveBookingRuleModel =
$dealMatchingBookingRules.getSingleMatchingLevel1BookingRule();
effectiveBookingRuleModel.applyRuleOnDeal($dealMatchingBookingRules.getDeal());
retract($dealMatchingBookingRules);
end