Drools 6 VS Drools 5 Performance and Drools 6 is Very slow

1,615 views
Skip to first unread message

Ashish Soni

unread,
Jul 15, 2015, 10:04:45 PM7/15/15
to drools...@googlegroups.com
Hi All ,

I am seeing great amount of performance degrade when i use Drools 6 VS Drools 5 , I am processing 15 million record using Apache Spark across  the cluster of 6 Nodes  , Same Rule file same class Object and Same Stateless Session

With Drool 5 it took 25 seconds to process all the data with Drools 6 it took 5.2 min , Please Suggest if there is something i am missing

See below Code Files and Rule file attached .

Thanks,



Charge.java
kmodule.xml
myrule.drl
RateDriver.java
SimpleRating.java

Mario Fusco

unread,
Jul 16, 2015, 3:46:56 AM7/16/15
to drools...@googlegroups.com
Hi,

If I'm understanding correctly the SimpleRating and RateDriver classes are supposed to do the same thing respectively with Drools 5 and 6. If so the comparison you're making is ABSOLUTELY NOT FAIR.

In SimpleRating you compile the drl and create the KnowledgeBase OUT of the Spark callback and then for each callback you instance a new StatelessKnowledgeSession out of that KnowledgeBase and this is indeed the correct way to proceed.

Conversely in RateDriver you do everything INSIDE the callback and then you're recompiling the drl and creating a new KieBase out of it 15 million times!

Try to move this code out of the callback

    KieServices kieServices = KieServices.Factory.get();
    KieContainer kContainer = kieServices.getKieClasspathContainer();
    final KieBase kbase = kContainer.newKieSession("HelloWorldKB");

and then inside it just do

    StatelessKieSession ksession = kbase.newStatelessKieSession();

I hope this help.

Mario


--
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...@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/f64f670d-260b-495b-b2bb-c65bb3fab78c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ashish Soni

unread,
Jul 16, 2015, 8:14:37 AM7/16/15
to drools...@googlegroups.com
Below code you provided is not working as kcontainer doesnt retuen a KBASE but return a session.



Try to move this code out of the callback

    KieServices kieServices = KieServices.Factory.get();
    KieContainer kContainer = kieServices.
getKieClasspathContainer();
    final KieBase kbase = kContainer.newKieSession("HelloWorldKB");


Mark Proctor

unread,
Jul 16, 2015, 8:27:27 AM7/16/15
to drools...@googlegroups.com


On Thursday, 16 July 2015, Ashish Soni <ashish...@gmail.com> wrote:
Below code you provided is not working as kcontainer doesnt retuen a KBASE but return a session.


Try to move this code out of the callback

    KieServices kieServices = KieServices.Factory.get();
    KieContainer kContainer = kieServices.
getKieClasspathContainer();
    final KieBase kbase = kContainer.newKieSession("HelloWorldKB");


That was an obvious typo, try newkieBase 
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/f742b061-6d1a-46e3-9216-638a2801bbcb%40googlegroups.com.

Ashish Soni

unread,
Jul 16, 2015, 8:42:38 AM7/16/15
to drools...@googlegroups.com
I tried the same and when i packaged inside the JAR it doesn't work , I tried all possible combination
created a config directory and placed all the DRL files inside that and added that in classpath and KModule is inside META-INF with empty tag but gets below error

Can some please help me where should the DRL file reside in the classpath and where should the Kmodule.xml for stateless session as nothing works with Drools and there is no proper example of doing that .. i will create an example and post it once it start working in a packaged JAR

column=0
   text=[ERR 102] Line 8:13 mismatched input '1' in rule "new rule"], Message [id=3, level=ERROR, path=org/drools/compiler/lang/dsl/rule1.drl, line=0, column=0
   text=Parser returned a null Package]]

Mark Proctor

unread,
Jul 16, 2015, 9:03:09 AM7/16/15
to drools...@googlegroups.com
This is confusing. First you say there is a performance issue, now looking below your stuff couldn't have worked as you have a problem in your drl file.


On Thursday, 16 July 2015, Ashish Soni <ashish...@gmail.com> wrote:
I tried the same and when i packaged inside the JAR it doesn't work , I tried all possible combination
created a config directory and placed all the DRL files inside that and added that in classpath and KModule is inside META-INF with empty tag but gets below error

Can some please help me where should the DRL file reside in the classpath and where should the Kmodule.xml for stateless session as nothing works with Drools and there is no proper example of doing that ..
There are about 10 different examples for this, which are documented. 
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/41ede47b-4f3e-4b52-ad6c-0a838b84358a%40googlegroups.com.

Ashish Soni

unread,
Jul 16, 2015, 10:05:39 AM7/16/15
to drools...@googlegroups.com
You are Adulterously correct Mark , it is frustrating and confusing as there is no consistent behaviour or i do not know how it should work , Please explain / help
Everything works when i create the session inside the call back with below line and not using KieBase - line in Green work and line in RED doesnt work

StatelessKieSession ksession = kbase.newStatelessKieSession();  // does not work

StatelessKieSession ksession =kContainer.newStatelessKieSession("HelloWorldKS");  // it works.

Please find the complete JAR Here

https://drive.google.com/file/d/0B--LI-1OKy_NMGlULWZKak04bnM/view?usp=sharing

Ashish

Mark Proctor

unread,
Jul 16, 2015, 10:23:28 AM7/16/15
to drools...@googlegroups.com
You need to read up on default and named kiesessions. documented examples exist for both.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/fc957ee1-f89e-42f6-93cc-a8be9ebd5fa8%40googlegroups.com.

Davide Sottara

unread,
Jul 16, 2015, 7:57:07 PM7/16/15
to drools...@googlegroups.com
Ashish, you can find examples here:

https://github.com/droolsjbpm/drools/tree/master/drools-examples-cdi

I am trying to understand how you created the JAR you attached. 
The reason for the DRL compilation error you get sometimes is that a *DSL* (not DRL) "rule1.drl" file example was pulled in
and apparently gets tentatively compiled. 

In Drools 6 there are slightly different "styles" to create knowledge bases, what you probably want to do is pick one and be consistent with it.
Kie JARs are meant to maximize deployability and reusability, but you'd want to create the KJAR independently and then use it from your application.

Otherwise, for a more drools-5 (resource-in-app-oriented) style, you may want to consider the KieHelper

Hope this helps

btw Mario's reccomendation is absolutely correct. You want to create the KieBase once, then get the KieSessions as you need them

Ashish Soni

unread,
Jul 17, 2015, 8:21:00 AM7/17/15
to drools...@googlegroups.com
Thanks a lot.

jco

unread,
Jul 17, 2015, 9:13:59 AM7/17/15
to drools...@googlegroups.com
Greetings:

I ran some benchmarks on Drools 6.1/6.2 some time ago and I found the performance of Drools 6 to be about 20-25 percent faster than Drools 5.  These were the standard Univ of Texas OPS benchmarks.

jco

Ashish Soni

unread,
Jul 17, 2015, 10:08:50 AM7/17/15
to drools...@googlegroups.com
Can you shed some more light on below or if there are any recommendation or tuning steps .

Ashish
Reply all
Reply to author
Forward
0 new messages