Inconsistency in Drools' Performance (Version 5.5.0)
by Harpreet Singh
Hi,
I have been trying to measure Drools' 5.5.0 performance for quite some time. I see that Drools' perform inconsistently in terms of CPU time.
Please see the below code (modification of DroolsTest example):
/*Code start*/
public class DroolsTest {
public static final void main(String[] args) {
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
// go !
for (int i = 0; i < 20; i++) {
Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
long startTime = System.nanoTime();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
FactHandle handle = ksession.insert(message);
ksession.fireAllRules();
ksession.retract(handle);
System.out.println("Time taken is: " + (System.nanoTime()-startTime)/1000);
ksession.dispose();
}
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
}
}
/** Code end**/
I have just added timing code to the DroolsTest.java program (provided by JBoss) and I am using Sample.drl file (provided by JBoss). The rules get executed correctly but the timings that I see are:
Iteration 1: 103753 (we can ignore this as the classes get loaded during the first iteration)
Iteration 2: 861
Iteration 3: 744
Iteration 4: 1350
Iteration 5: 718
Iteration 6: 651
Iteration 7: 661
Iteration 8: 668
Iteration 9: 648
Iteration 10: 3564
Iteration 11: 911
Iteration 12: 689
Iteration 13: 682
Iteration 14: 796
Iteration 15: 4236
Iteration 16: 774
Iteration 17: 772
Iteration 18: 722
Iteration 19: 713
Iteration 20: 697
I profiled it with Yourkit Profiler and the increase in time does not correspond to garbage collection. I also timed individual calls and found out that:
- ksession.insert: takes consistent time
- ksession.fireAllRules: inconsistent
- kbase.newStatefulKnowledgeSession: inconsistent
I see same inconsistency in performance when I integrate Drools with original project (which I can't share here). I also found that this has nothing to do with compiler optimizations.
Why is there inconsistent performance? Is there anything that I am missing?
Thank you.
10 years, 11 months
permgen error for simple rule stress test
by anjana.ackroyd
We are running a simple stress test (whose code I will paste below) for a
numbercompare rule file)
We get the following error before the test finishes. Which seems odd for one
rule
javax.servlet.ServletException: java.lang.OutOfMemoryError: PermGen space
This test is run against 3 loablanced tomcat servers
Here is my JVM_OPTS for each of those tomcat
JVM_OPTS="-Xms4096m -Xmx4096m -XX:NewSize=2048m -XX:PermSize=512m
-XX:MaxPermSize=512m -Xss1024K -XX:+UseCodeCacheFlushing
-XX:-UseSplitVerifier"
Here is
I have a simple rule file deployed on guvnor on my abc with JVM_OPTS on the
guvnor being
JVM_OPTS="-Xms4096m -Xmx4096m -XX:NewSize=2048m -XX:PermSize=512m
-XX:MaxPermSize=512m -Xss1024K
Here is my stress test that we are running
package DroolsTest;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import confident.guppy.tools.Caller;
public class DroolsSpeedTest {
public static void main(String[] args) {
HttpURLConnection httpURLConnection = null;
InputStream inputStream = null;
BufferedReader bufferedReader = null;
long t1 = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
try {
long start =
System.currentTimeMillis();
// Three
boxes
String url =
"https://abc-uat2.xyz.com/ces/v2.0/rules/10/compare/10";
httpURLConnection = (HttpURLConnection) ( new URL(url).openConnection());
if
(httpURLConnection != null) {
inputStream = httpURLConnection.getInputStream();
bufferedReader = new BufferedReader(new InputStreamReader(
inputStream));
String results = "";
String info = "";
while ((info = bufferedReader.readLine()) != null) {
results += info;
}
//caller.log(results);
} else {
System.out.println("Unable to create the HTTP connection with the required
server...");
}
if (i % 20
== 0 && i != 0 ) {
System.out.println(" passing " + i + " ms " + (
System.currentTimeMillis() - start ));
}
} catch (Exception boom) {
boom.printStackTrace();
System.out.println("It died on the " + i + " attempt because " +
boom.getMessage());
}
}
long t2 = System.currentTimeMillis() - t1 ;
System.out.println("I took ms : "+ t2 );
}
}
Here is my rules defined on guvnor
package org.numbercompare;
declare NumberCompare
message : String
numberone: Integer
numbertwo: Integer
end
rule "numberone is equals to numbertwo"
when
n: NumberCompare(numberone == numbertwo);
then
n.setMessage("numberone is equals to numbertwo");
end
rule "numberone is greater than numbertwo"
when
n: NumberCompare(numberone > numbertwo);
then
n.setMessage("numberone is greater than numbertwo");
end
rule "numberone is less than numbertwo"
when
n: NumberCompare(numberone < numbertwo);
then
n.setMessage("numberone is less than numbertwo");
end
Here is my code that updates the rule file
public KnowledgeBase readKnowledgeBase() throws Exception {
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "2");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
KnowledgeAgentConfiguration kaconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
kaconf.setProperty("drools.agent.scanDirectories", "true");
kaconf.setProperty("drools.agent.scanResources", "true");
kaconf.setProperty("drools.agent.newInstance", "false");
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("CS", kaconf);
kagent.applyChangeSet(ResourceFactory.newClassPathResource("ChangeSet.xml"));
KnowledgeBase kbase = kagent.getKnowledgeBase();
return kbase;
}
@Override
public DroolsDTO getDroolsDTO(int numberone, int numbertwo) throws
Exception {
DroolsDTO droolsDTO = new DroolsDTO();
KnowledgeBase kb = readKnowledgeBase();
FactType factType = kb.getFactType("org.numbercompare",
"NumberCompare");
Object nc = factType.newInstance();
factType.set(nc, "numberone", numberone);
factType.set(nc, "numbertwo", numbertwo);
StatefulKnowledgeSession ksession =
kb.newStatefulKnowledgeSession();
ksession.insert(nc);
ksession.fireAllRules();
ksession.dispose();
droolsDTO.setMessage(factType.get(nc, "message").toString());
return droolsDTO;
}
My changeset.xml
<change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...'
>
<add>
<resource
source='http://abc:8082/guvnor/org.drools.guvnor.Guvnor/package/org.numbercompare...'
type='PKG' basicAuthentication="enabled" username="admin" password="admin"/>
</add>
</change-set>
Also in the guvnor logs during the test I see
, I see thousands of these: WARN 28-01 11:50:55,551
(RulesRepositoryManager.java:getRulesRepository:70) Creating RulesRepository
with default username. =============== session-guest-864931
and the session-guest numbers keep climbing.
and admin user logging in about every second.
--
View this message in context: http://drools.46999.n3.nabble.com/permgen-error-for-simple-rule-stress-te...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Intermittent startup error with Integration Server?
by dunnlow
I'm using the Drools Integration server (5.5) (with a persisted stateful
ksession) and a java client that is sending events via httpclient.
Most of the time, things work fine. Sometimes, when I restart the
integration server, when it comes back up I I start getting messages (all
following msgs to the server fail with a 500 (internal) error):
org.apache.cxf.jaxrs.impl.WebApplicationExceptoinMapper toResponse
WARNING: WebApplicationException has been caught : No converter
specified for class org.drools.command.runtime.BatchExceutionCommandImpl
---- Debugging information ----
version : null
-------------------------------
To fix this problem, I need to:
1) stop the client sending messages to the integration server,
2) restart the integration server
3) once it's up, I send a single message (which is successfully processed)
4) turn the client back on, and everything is just fine.
It appears as if the Integration server doesn't like receiving messages as
it is coming up. Does anyone have any thoughts about what is going on here
and how to mitigate?
Thanks,
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Intermittent-startup-error-with-Integra...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Mvel "in" operator and Inline List Question (Elements with range)
by mattmadhavan
Hello,
I see the example mvel "in" operator for the inline array as follows:
surgeryCode in [00, 12, 13, 15, 19, *20, 21, 22, 23, 24, 25*, 30, 33, 45,
48, 55, 56, 65, 66, 70, 80, 90, 99]
If you notice above the codes *21 to 25* are contiguous (Range)
Is it possible to specify in the list a 'short hand' notation like 21-25
like as follows:
surgeryCode in [00, 12, 13, 15, 19, 20, *21-25*, 30, 33, 45, 48, 55, 56, 65,
66, 70, 80, 90, 99]
If Drools does not support it, is writing my own Custom Operator is my only
option?
Thanks in advance!
Matt'M
--
View this message in context: http://drools.46999.n3.nabble.com/Mvel-in-operator-and-Inline-List-Questi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Drools 6 performance
by Mark Proctor
If anyone has tried 6.0 and seeing performance gains, please contact us. We want to find the real world use cases that benefit from the lazy evaluation.
Mark
10 years, 11 months
Pooling KnowledgeBase instances
by travistcummings
Hi,
I am running into an issue in a highly concurrent environment where my
threads are waiting on locking of the rule base when I try to insert into
the session. I am wondering if an appropriate solution would be to create a
pool of KnowledgeBase objects, each having its own rule base. A thread dump
of my server had the message below for about 40 threads.
For my use case, I create the knowledge base once, then don't modify it in
any way.
Thank you!
Travis
"ajp-bio-8010-exec-984" daemon prio=10 tid=0x081f3800 nid=0x2a7c waiting on
condition [0x9f368000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0xf0489a50> (a
java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
at
java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:945)
at
org.drools.common.UpgradableReentrantReadWriteLock.lowPriorityWriteLock(UpgradableReentrantReadWriteLock.java:105)
at
org.drools.common.UpgradableReentrantReadWriteLock.writeLock(UpgradableReentrantReadWriteLock.java:88)
at org.drools.common.AbstractRuleBase.lock(AbstractRuleBase.java:475)
at
org.drools.reteoo.builder.PatternBuilder.attachObjectTypeNode(PatternBuilder.java:276)
at
org.drools.reteoo.ClassObjectTypeConf.<init>(ClassObjectTypeConf.java:103)
at
org.drools.common.ObjectTypeConfigurationRegistry.getObjectTypeConf(ObjectTypeConfigurationRegistry.java:71)
at org.drools.reteoo.Rete.assertObject(Rete.java:107)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:286)
at
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:434)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:993)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:335)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
--
View this message in context: http://drools.46999.n3.nabble.com/Pooling-KnowledgeBase-instances-tp40279...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Drools - Processing large volume of (Same Type) Facts with muliple complex Rules groups
by mattmadhavan
Hello,
I have a few questions on Drools.
* My client has millions of rows of Facts of same type , to which the rules
are applied. The facts are never updated.
* There is multiple set of Rule groups (Cancer type can be
Breast/Colon/Thyroid etc), with each group containing multiple rules in a
separate .drl file (BeastCancer.drl, ColonCancer.drl etc).
I have the following requirements/questions
1) Each group has a first rule that checks for Cancer type - If the caner
type is not the one for this group (Say the CaseFact is for Colon but the
current rule group is for Breast) the rule flow should stop for this group
and continue for other groups. I guess I can achieve this by having my first
rule with a high Salience and skip the rest of the rules if the condition is
met. (drools.clearAgenda () may be ?)
2) within a group of rules - I need to skip the execution for rest of rules
in this group only depending on the condition.
3) Some conditional flow (I believe I can achieve this with Rule Flow
Group).
4) Should I have have one KnowledgeBase/Stateless session per .drl file (one
per beast.drl one for colon.drl)? That seems to be the logical thing to!
5) Main question is how do I skip execution of a set of rules
I appreciate in advance!
Thanks
Matt'M
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Processing-large-volume-of-Same-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Null pointer exception when using global in rdrl 6.0.1.F
by SrjTx
I have a class that I declared final, has a private constructor, has only
static members and methods.
Some of its members are static instance of classes.
In KIE-WBI added a global of that type with name X
When I try to make a call on X.foo(), I get a null pointer exception. (note
that x.foo() calls y.foo(), where y is a static member of X.
I've read some posts that a global has to be static, am I stretching, what
it means for a global to be static?
I am guessing I need to write some java code that will create an instance of
X and inject into working memory? I was hoping to be able to create this
object within either the drools or SY framework.
I have googled and be reading on this for quite a bit now, but I think I
have succeeded only in confusing myself.
Any help greatly appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/Null-pointer-exception-when-using-globa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Re: [rules-users] Drools, slf4j and Eclipse Error on DroolsTest.Java
by Inastrol
Figured out the problem. Didn't have Maven installed as a plug-in
correctly. The book I'm using to learn Drools, didn't include that step.
Terry Moriarty wrote:
> This isn't my code. It's created when a Drools project is created in
> Eclipse. I guess that's why this is so frustrating. It's supposed to
> demonstrate a very simple Drools program and I can't get it to work.
> It's hard to debug someone else's code when you don't know the
> language yet.
>
> Code is kSession.insert(message);
>
> Thanks
>
> sdjoe [via Drools] wrote:
>
>> Hard to say without seeing your code. Can you post it here and point
>> out where the NPE is happening on line 23?
>>
>> ------------------------------------------------------------------------
>> If you reply to this email, your message will be added to the
>> discussion below:
>> http://drools.46999.n3.nabble.com/Drools-slf4j-and-Eclipse-Error-on-Drool...
>>
>> To unsubscribe from Drools, slf4j and Eclipse Error on
>> DroolsTest.Java, click here
>> <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscr...>.
>> NAML
>> <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_vi...>
>>
>
>------------------------------------------------------------------------
>
>package com.sample;
>
>import org.kie.api.KieServices;
>import org.kie.api.runtime.KieContainer;
>import org.kie.api.runtime.KieSession;
>
>/**
> * This is a sample class to launch a rule.
> */
>public class DroolsTest {
>
> public static final void main(String[] args) {
> try {
> // load up the knowledge base
> KieServices ks = KieServices.Factory.get();
> KieContainer kContainer = ks.getKieClasspathContainer();
> KieSession kSession = kContainer.newKieSession("ksession-rules");
>
> // go !
> Message message = new Message();
> message.setMessage("Hello World");
> message.setStatus(Message.HELLO);
> kSession.insert(message);
> kSession.fireAllRules();
> } catch (Throwable t) {
> t.printStackTrace();
> }
> }
>
> public static class Message {
>
> public static final int HELLO = 0;
> public static final int GOODBYE = 1;
>
> private String message;
>
> private int status;
>
> public String getMessage() {
> return this.message;
> }
>
> public void setMessage(String message) {
> this.message = message;
> }
>
> public int getStatus() {
> return this.status;
> }
>
> public void setStatus(int status) {
> this.status = status;
> }
>
> }
>
>}
>
>
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-slf4j-and-Eclipse-Error-on-Drool...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Drools 6 and Gradle?
by Andrew Berman
Hello,
I keep running into an issue where Drools is looking for a pom.properties
file and I get an error since I'm using Gradle. Does Drools depend on
Maven? I noticed there is a lot of code looking for Maven and pom.xml and
pom.properties, why is that?
Thanks!
10 years, 11 months