Multi-threading inefficiency caused by static class synchronization?
by ping
hi,
I'm new to Drools and I'm doing some performance benchmark to see if I can
scale up a StatelessSession engine. I did the benchmark on a 8 core machine
but the results shows the engine can only take advantage of 1.5 cores at any
time.
here is my tests:
1. create a KnowledgeBase
2. started multiple threads (I tried 4/8/16 threads) running same loop:
create a stateless session from KnowledgeBase and create a new fact, then
insert the fact into the session.
After running the test for multiple times I found that it can only utilize
at most 1.5 cores at the same time.
I also found that most of time threads were blocked by static class locks
like:
public static synchronized ProcessRuntimeFactoryService
getProcessRuntimeFactoryService()
Anyone has experience scaling up a stateless drools engine?
Thanks a lot.
-Ping
--
View this message in context: http://drools.46999.n3.nabble.com/Multi-threading-inefficiency-caused-by-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Drools hangs on parsing a Query
by spotlight2001
*Drools 5.4.0.Final*
Im running a *query* against Drools
It is running for many hours and doesnt seem to return.
This happens in 5% on production. Probably some race problem?
...
query "distributeForMove" (long pSpmaId)
$spma: SubPlanningMatrixOpt ( ..., spmaId == pSpmaId, ...)
...
On suspending the thread
I see that Drools tries to resolve "pSpmaId" as a class
Thread is in status "RUNNABLE"
"jmsWaitingMessageListenerContainer-1" prio=10 tid=0x00002aaed49ad000
nid=0x1719 runnable [0x00000000440e1000]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.getEntry(Unknown Source)
at java.util.HashMap.containsKey(Unknown Source)
at
org.drools.util.CompositeClassLoader$CachingLoader.load(CompositeClassLoader.java:244)
at
org.drools.util.CompositeClassLoader$CachingLoader.load(CompositeClassLoader.java:237)
at
org.drools.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:88)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at
org.mvel2.ParserConfiguration.checkForDynamicImport(ParserConfiguration.java:159)
at org.mvel2.ParserConfiguration.hasImport(ParserConfiguration.java:187)
at org.mvel2.ParserContext.hasImport(ParserContext.java:352)
at
org.mvel2.compiler.AbstractParser.createPropertyToken(AbstractParser.java:1331)
at org.mvel2.compiler.AbstractParser.nextToken(AbstractParser.java:836)
at
org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:128)
at
org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:62)
at org.mvel2.MVEL.compileExpression(MVEL.java:810)
at
org.drools.rule.constraint.MvelConditionEvaluator.<init>(MvelConditionEvaluator.java:34)
at
org.drools.rule.constraint.MvelConstraint.createMvelConditionEvaluator(MvelConstraint.java:179)
at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:157)
at
org.drools.rule.constraint.MvelConstraint.isAllowedCachedLeft(MvelConstraint.java:136)
at
org.drools.common.SingleNonIndexSkipBetaConstraints.isAllowedCachedLeft(SingleNonIndexSkipBetaConstraints.java:125)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:96)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:232)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:89)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:98)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:196)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:145)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:154)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:364)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertQuery(EntryPointNode.java:146)
at
org.drools.reteoo.ReteooWorkingMemory.getQueryResults(ReteooWorkingMemory.java:189)
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-hangs-on-parsing-a-Query-tp40211...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Rules not properly re-evaluating in 5.5
by CyBurr
If am using a Stateful knowledge session with a rule flow group. I am
inserting into working memory one instance of each class/type listed below.
All of the rules fire except for rule 14. Rule 14 and 15 are very similar
but for some reason only rule 15 fires. If I swap the physical order of 14
and 15 in the DRL file then rule 14 fires and 15 does NOT. If I change the
order of the LHS conditions for rules 14 and 15 then both rules fire. I am
assuming the order of the LHS conditions or physical order of the rules is
irrelevant. Is that the case? If so, then can someone tell me what I’m
doing wrong?
//*******************Classes/Types***********************************
DRuleContext.java (annotated with @PropertyReactive):
boolean elig;
Date date;
Person.java
String typeID;
String status;
DDE (declared type in Drools. Annotated with @propertyReactive)
drvYear : Integer;
drvStartYear: Integer;
drvEndYear : Integer;
//**********************RULES*****************************************
rule "2"
ruleflow-group "MyGroup"
date-effective "01-Jan-2008"
when
$aPerson : Person( typeID == "AE", status == "S")
$aResponse : DRuleContext()
then
modify ($aResponse) { setElig(true) };
end
rule "12"
ruleflow-group "MyGroup"
date-effective "01-Jan-2008"
when
$aResponse : DRuleContext()
eval(getMonthOfTheDate($aResponse.getDate()) > 6)
$dde : DDE()
then
modify($dde){setDrvYear( getYearOfTheDate($aResponse.getDate()))};
modify($dde){setDrvEndYear ( $dde.getDrvYear() + 1)};
modify($dde){setDrvBeginYear( getYearOfTheDate($aResponse.getDate()))};
end
rule "14"
ruleflow-group "MyGroup"
date-effective "01-Jan-2008"
when
$aResponse : DRuleContext( elig==true)
$dde : DDE( drvBeginYear!=null )
then
modify ($aResponse)
{setFsaStartDate(createDate(07,01,$dde.getDrvBeginPlanYear())) };
end
rule "15"
ruleflow-group "MyGroup"
date-effective "01-Jan-2008"
when
$aResponse : DRuleContext( elig==true)
$dde : DDE( drvEndYear!=null )
then
modify ($aResponse)
{setFsaEndDate(createDate(06,30,$dde.getDrvEndPlanYear())) };
end
--
View this message in context: http://drools.46999.n3.nabble.com/Rules-not-properly-re-evaluating-in-5-5...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Problem with KnowledgeBase updates in Guvnor and the Fusion temporal rules with time intervals
by Adrián Paredes
Hi all:
I have a Guvnor Repository with same rules.
Then, I have a web application with a KnowledgeAgent. The agent has the
"drools.agent.newInstance" property in "false", to update the
KnowledgeStatefulSession with every change in the KnowledgeBase, and the
scanning interval setted in 10 seconds.
In my rules, I use temporal operator of Fusion with "befores" and "afters",
and time intervals.
In my web application I have a long running KnowledgeStatefulSession and I
use an AgendaEventListener to fire rules in every activationCreated() event.
My problem is that in each KnowledgeBase update, the session cancels all
the activations created and then creates all activations cancelled again. I
see this because I have a logger in each method of the AgendaEventListener
instance.
If I had a rule of this style in progress:
rule "Basic Rule"
dialect 'mvel'
when
$eventA: EventA($aId: id) from entry-point "time stream"
not EventB($aId == id, this after [0s,5m] $eventA) from entry-point
"time stream"
then
System.out.println("Event A " + $aId + " at " + $eventA.timestamp);
end
And this rule had been activated 2 minutes ago... When the KnowledgeAgent
updates the KnowledgeSession, after a KnowledgeBase update from Guvnor, the
time intervals resets to zero. I guess it must be because the agent cancels
the activations and creates them again.
The result is that the System.out fires 7 minutes after the event was
inserted... 2 minutes later.
I hope you have understood me, despite my english.
Thanks!!
Adrian
--
*Epidata Consulting | Deploying Ideas
Ing. Adrián M. Paredes | Arquitecto Desarrollador
adrianp(a)epidataconsulting.com | Cel: (54911) 3297 1713
----------------------------------------------------------------------------------------------------------------------------
Argentina: Maipú 521 Piso 1 Of. A | Buenos Aires | Of: (5411) 5031 0060
Chile: Apoquindo 3600 Piso 7 y 9 | Las Condes - Santiago | Of: (+56) 2 495
8450
---------------------------------------------------------------------------------------------------------------------------
www.epidataconsulting.com
Linkedin <http://bit.ly/epidatalinkedin> |
Facebook<http://www.facebook.com/epidata.consulting>
| Twitter <http://twitter.com/epidata>
*
12 years
A basic doubt about Drools Fusion
by Adrián Paredes
Hi all:
I have a very basic doubt about Drools Fusion.
I have two simple Java classes:
EventA {
String id;
Date timestamp;
Long duration;
}
EventB {
String id;
Date timestamp;
Long duration;
}
I have a DRL file, where I declare this two classes as Events:
declare EventA
@role(event)
@timestamp(timestamp)
@duration(duration)
end
declare EventB
@role(event)
@timestamp(timestamp)
@duration(duration)
end
I have a simple rule:
rule "Basic Rule"
dialect 'mvel'
when
$eventA: EventA($aId: id) from entry-point "time stream"
then
System.out.println("Event A " + $aId + " at " + $eventA.timestamp);
end
Finally, I have a test that starts a StatefulKnowledgeSession in STREAM
mode, register an eventLister in the session in order to fire the rules
when an event arrives:
ksession.addEventListener(new DefaultAgendaEventListener() {
@Override
public void activationCreated(ActivationCreatedEvent event) {
((StatefulKnowledgeSession)
event.getKnowledgeRuntime()).fireAllRules();
}
});
And then the test insert in the "time stream" entry-point an instance of
EventA with duration of 10 miliseconds, as follows:
EventA eventA = new EventA();
eventA.setId("123");
eventA.setTimestamp(new Date());
eventA.setDuration(10L);
ksession.getWorkingMemoryEntryPoint("time stream").insert(event);
At the end of the test, I have an sleep of 2 seconds just in case.
I don't understand why the "Basic Rule" never fires.
But if I add another condition to the same rule, something like this:
rule "Basic Rule"
dialect 'mvel'
when
$eventA: EventA($aId: id) from entry-point "time stream"
not EventB($aId == id, this after [0s,5s] $eventA) from entry-point
"time stream"
then
System.out.println("Event A " + $aId + " at " + $eventA.timestamp);
end
The rules fires and I see this message in console:
Event A 123 at Fri Dec 07 09:48:59 ART 2012
I don't understand why the first rule, that is more open, don't fire, and
the second rule, that is more restrictive, fires without problems.
Thank you very much!
Greetings,
Adrian.
--
*Epidata Consulting | Deploying Ideas
Ing. Adrián M. Paredes | Arquitecto Desarrollador
adrianp(a)epidataconsulting.com | Cel: (54911) 3297 1713
----------------------------------------------------------------------------------------------------------------------------
Argentina: Maipú 521 Piso 1 Of. A | Buenos Aires | Of: (5411) 5031 0060
Chile: Apoquindo 3600 Piso 7 y 9 | Las Condes - Santiago | Of: (+56) 2 495
8450
---------------------------------------------------------------------------------------------------------------------------
www.epidataconsulting.com
Linkedin <http://bit.ly/epidatalinkedin> |
Facebook<http://www.facebook.com/epidata.consulting>
| Twitter <http://twitter.com/epidata>
*
12 years
Droold 5.4.0
by hare ram
Hi All,
I am newbie to Drools. I just downloaded drools-distribution-5.4.0.Final.
If I look at the binaries directory.
there are lots of jar files in it. I want to know what the minimum set of
jars i need to include in my classpath
to compile and run simple drl file.
Thanks
12 years
Referring other columns in Decision table data column
by jalex
Hi,
Can we have the decision table data columns to contain expressions that
refer to other columns, or is it just restricted to values? .For my
use-case, i need to have a rule like :
Condition : weight > 100 lb
Action : cost = $10 (fixed) + $5 for every lb above 100.
So, the data for this Action column would need to refer to the weight
column's data and do the calculation : 10 + (weight - 100) * 5.
Is this possible to specify this in decision table?
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Referring-other-columns-in-Decision-tab...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
DROOLs callback API for L-value predicate matching events
by Cotton, Ben
Hi, Can someone please point me to compelling examples/sample code of how to use a DROOLs callback API for very high-resolution logging of L-value predicate matching events?
E.g. I want to be able to log when each of these 5 L-value predicates either "MATCHES" or "FAILS TO MATCH" (at the time of the event)
rule "LCHUS_IRS_CURRENCY_RULE" //XLS Item=195
when
IRDCurrencyRuleFact(
productType == "IRS",
currency=="GBP",
upfrontFeePaymentDate < IRDCurrencyRuleFact.terminationDate,
maturity <= 18275, //unit = days, i.e. 50 Years
notional <= 99,999,999,999.99 //max Notional
)
then
System.out.println("LCHUS");
end
Ben D Cotton III
Morgan Stanley & Co.
OTC Derivatives Clearing Technology
1221 AOTA Rockefeller Ctr - Flr 27
New York, NY 10020
(212)762.9094
ben.cotton(a)ms.com<mailto:ben.cotton@ms.com>
________________________________
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.
12 years