Hi guys,
I have a questions regarding how to maintain the performance as the rule
engine fresh restarted when using stateless sessions (with drools 4.0.3).
We use drools in a web server to filter out unwanted facts coming from each
request. There are about 20 rules, but each request can have 500 to 2000
facts. We are trying to serve 10+ requests concurrently. Since it is pure
filtering, we use stateless sessions, with a singleton ruleBase; the
sequencial is set TRUE. We do remove the unwanted facts in our rules (RHS),
for example:
rule "Locale Restrictions"
when
$actionCollection : ActionFacts ()
$scoredAction : ScoredAction ( action.type == TYPE.LOCAL ) from
$actionCollection.scoredActions
$country : Country ()
eval ( $country != Country.UNITED_STATES )
then
if (logger.isDebugEnabled()) {
logger.debug("remove action " + $scoredAction.getAction() + "
from
action list because country is " + $country);
}
modifyRetract($actionCollection);
$actionCollection.getScoredActions().remove($scoredAction);
modifyInsert($actionCollection);
end
Every time we get a request, we file the rules like this:
ruleBase.newStatelessSession().execute(facts).
The problem is, when the rules engine just starts, it is very fast; on
average it can process 2 facts in 1 ms ( -- great work, guys!). However,
after a while ( a few thousands requests), it is slowing down; on average
processing each fact will take about 2 to 5 ms (4x to 10x slower). Since we
use stateless sessions, I expect the initial performance should be
maintained overtime. I did a thread dump, and found some threads in drools
are blocked (in a fresh restarted rule engine, I don't see these blockings):
Thread 20582: (state = BLOCKED)
- java.lang.Class.forName0(java.lang.String, boolean,
java.lang.ClassLoader) @bci=0 (Compiled frame; information may be imprecise)
- java.lang.Class.forName(java.lang.String) @bci=5, line=169 (Compiled
frame)
- org.mvel.util.ParseTools.resolveType(java.lang.Class) @bci=256, line=696
(Compiled frame)
- org.mvel.math.IEEEFloatingPointMath.doOperation(java.lang.Object, int,
java.lang.Object) @bci=29, line=24 (Compiled frame)
- org.mvel.util.ParseTools.doOperations(java.lang.Object, int,
java.lang.Object) @bci=6, line=767 (Compiled frame)
- org.mvel.ast.BinaryOperation.getReducedValueAccelerated(java.lang.Object,
java.lang.Object, org.mvel.integration.VariableResolverFactory) @bci=24,
line=20 (Compiled frame)
- org.mvel.MVELRuntime.execute(boolean, org.mvel.CompiledExpression,
java.lang.Object, org.mvel.integration.VariableResolverFactory) @bci=134,
line=88 (Compiled frame)
- org.mvel.CompiledExpression.getValue(java.lang.Object,
org.mvel.integration.VariableResolverFactory) @bci=15, line=108 (Compiled
frame)
- org.mvel.MVEL.executeExpression(java.lang.Object, java.lang.Object,
org.mvel.integration.VariableResolverFactory) @bci=6, line=230 (Compiled
frame)
- org.drools.base.mvel.MVELPredicateExpression.evaluate(java.lang.Object,
org.drools.spi.Tuple, org.drools.rule.Declaration[],
org.drools.rule.Declaration[], org.drools.WorkingMemory) @bci=22, line=36
(Compiled frame)
- org.drools.rule.PredicateConstraint.isAllowed(java.lang.Object,
org.drools.common.InternalWorkingMemory) @bci=15, line=210 (Compiled frame)
- org.drools.reteoo.FromNode.assertTuple(org.drools.reteoo.ReteTuple,
org.drools.spi.PropagationContext, org.drools.common.InternalWorkingMemory)
@bci=113, line=73 (Compiled frame)
-
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTuple(org.drools.common.InternalFactHandle,
org.drools.spi.PropagationContext, org.drools.common.InternalWorkingMemory)
@bci=26, line=73 (Compiled frame)
-
org.drools.reteoo.LIANodePropagation.doPropagation(org.drools.common.InternalWorkingMemory)
@bci=16, line=22 (Interpreted frame)
-
org.drools.common.AbstractWorkingMemory.fireAllRules(org.drools.spi.AgendaFilter,
int) @bci=41, line=448 (Compiled frame)
-
org.drools.common.AbstractWorkingMemory.fireAllRules(org.drools.spi.AgendaFilter)
@bci=3, line=434 (Compiled frame)
- org.drools.reteoo.ReteooStatelessSession.execute(java.util.Collection)
@bci=42, line=162 (Compiled frame)
My question is, is there something buit-up in the stateless session? how to
maintain the initial performance effectively?
Any suggestion is highly appreciated.
thanks
--
View this message in context:
http://www.nabble.com/Performance-Question-with-Stateless-Session-tp14704...
Sent from the drools - user mailing list archive at
Nabble.com.