Drools 4 poor performance scaling?
by Ron Kneusel
I am testing Drools 4 for our application and while sequential mode is very fast I get very poor scaling when I increase the number of facts for stateful or stateless sessions. I want to make sure I'm not doing something foolish before deciding on whether or not to use Drools because from what I am reading online it should be fast with the number of facts I have.
The scenario: I have 1000 rules in a DRL file. They are all of the form:
rule rule0000
when
Data(type == 0, value> 0.185264);
Data(type == 3, value < 0.198202);
then
insert(new AlarmRaised(0));
warnings.setAlarm(0, true);
end
where the ranges checked on the values and the types are randomly generated. Then, I create a Stateful session and run in a loop timing how long it takes the engine to fire all rules as the number of inserted facts increases:
// Run
for(j=0; j < 100; j+=5) {
if (j==0) {
nfacts = 1;
} else {
nfacts = j;
}
System.out.println(nfacts + ":");
// Get a working memory
StatefulSession wm = ruleBase.newStatefulSession();
// Global - output
warnings = new Alarm();
wm.setGlobal("warnings", warnings);
// Add facts
st = (new Date()).getTime();
for(i=0; i < nfacts; i++) {
wm.insert(new Data(rand.nextInt(4), rand.nextDouble()-0.5));
}
en = (new Date()).getTime();
System.out.println(" facts = " + (en-st));
// Now run the rules
st = (new Date()).getTime();
wm.fireAllRules();
en = (new Date()).getTime();
System.out.println(" rules = " + (en-st));
// Clean up
wm.dispose();
System.out.println("\n");
}
This code is based on the HelloWorldExample.java code from the manual and the setup for the rule base is the same as in the manual. As the number of facts increases runtime increases dramatically:
facts -- runtime (ms)
10 -- 168
20 -- 166
30 -- 344
40 -- 587
50 -- 1215
60 -- 1931
70 -- 2262
80 -- 3000
90 -- 4754
with a maximum memory use of about 428 MB RAM. By contrast, if I use sequential stateless sessions, everything runs in about 1-5 ms.
Is there something in my set up that would cause this, or is this how one would expect Drools to scale? I read about people using thousands of facts so I suspect I'm setting something up incorrectly.
Any help appreciated!
Ron
_________________________________________________________________
The other season of giving begins 6/24/08. Check out the i’m Talkathon.
http://www.imtalkathon.com?source=TXT_EML_WLH_SeasonOfGiving
17 years, 11 months
java.util.NoSuchElementException in buildAsset
by Sergio Stateri Jr
Hi,
I have installed BRMS (Drools 5) and create a repository for BRMS. When
I create a simple rule, like:
when
$object: Object()
then
System.out.println("ok");
end
all works fine, but... When I create a complex rule, using my own complex
classes and click in the validate button, the following error is reported
:
Error
An error occurred executing the action.
java.util.NoSuchElementException at java.util.StringTokenizer.nextToken(StringTokenizer.java:332)
at org.codehaus.janino.UnitCompiler.findClass(UnitCompiler.java) at org.codehaus.janino.Compiler$CompilerIClassLoader.findIClass(Compiler.java)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java) at org.codehaus.janino.UnitCompiler.reclassifyName(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.reclassifyName(UnitCompiler.java) at
org.codehaus.janino.UnitCompiler.reclassify(UnitCompiler.java) at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.access$114(UnitCompiler.java) at org.codehaus.janino.UnitCompiler$15.visitAmbiguousName(UnitCompiler.java)
at org.codehaus.janino.Java$AmbiguousName.accept(Java.java) at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java) at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.access$104(UnitCompiler.java) at org.codehaus.janino.UnitCompiler$15.visitMethodInvocation(UnitCompiler.java)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java) at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java) at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.access$51(UnitCompiler.java) at org.codehaus.janino.UnitCompiler$9.visitMethodInvocation(UnitCompiler.java)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java) at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java) at
org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java) at org.codehaus.janino.UnitCompiler.access$25(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler$6.visitMethodInvocation(UnitCompiler.java)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java) at org.codehaus.janino.UnitCompiler.access$8(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler$4.visitExpressionStatement(UnitCompiler.java)
at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java) at org.codehaus.janino.UnitCompiler.access$7(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler$4.visitBlock(UnitCompiler.java) at org.codehaus.janino.Java$Block.accept(Java.java)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java)
at org.codehaus.janino.UnitCompiler$3.visitPackageMemberClassDeclaration(UnitCompiler.java)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java) at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java)
at org.codehaus.janino.Compiler.compile(Compiler.java) at org.drools.commons.jci.compilers.JaninoJavaCompiler.compile(JaninoJavaCompiler.java:174)
at org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:51)
at org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:394)
at org.drools.compiler.DialectRegistry.compileAll(DialectRegistry.java:60)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:324)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:168)
at org.drools.brms.server.contenthandler.DRLFileContentHandler.compile(DRLFileContentHandler.java:32)
at org.drools.brms.server.builder.ContentPackageAssembler.buildAsset(ContentPackageAssembler.java:139)
at org.drools.brms.server.builder.ContentPackageAssembler.buildPackage(ContentPackageAssembler.java:127)
at org.drools.brms.server.builder.ContentPackageAssembler.(ContentPackageAssembler.java:84)
at org.drools.brms.server.builder.ContentPackageAssembler.(ContentPackageAssembler.java:92)
at org.drools.brms.server.ServiceImplementation.buildPackage(ServiceImplementation.java:897)
at org.drools.brms.server.ServiceImplementation.buildPackage(ServiceImplementation.java:887)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:40)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
at org.drools.brms.server.ServiceImplementation_$$_javassist_3.buildPackage(ServiceImplementation_$$_javassist_3.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.seam.remoting.gwt.GWTToSeamAdapter.callWebRemoteMethod(GWTToSeamAdapter.java:85)
at org.jboss.seam.remoting.gwt.GWTRemoteServiceServlet.processCall(GWTRemoteServiceServlet.java:320)
at org.jboss.seam.remoting.gwt.GWTRemoteServiceServlet.doPost(GWTRemoteServiceServlet.java:188)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42) at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:46)
at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:595)
I have created my models, categories and packages using the BRMS interface.
Then, I have no idea how to solve this problem, and the brms code doesn?t
show the line numbers before StringTokenizer class (I could see the error
cause in the brms source code, but the "UnitCompiler.java" is shown in the
line number position, why ?).
Thanks for any help.
Sergio Stateri Jr.
sergio.stateri(a)globo.com
17 years, 11 months
problems with desicion tables
by Vanina Beraudo
Hi,
I am working with decition tables, I have differents xls files with
rules and I want to add multiple xls files to the same rulebase and
they will be merged into a single package.
I do the following:
private static RuleBase readTablaDecision() throws Exception {
//read in the source
final SpreadsheetCompiler converter = new SpreadsheetCompiler();
final String drl = converter.compile( "/reglaPrincipal.xls",
InputType.XLS );
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new StringReader( drl ) );
final String drl2, drl3;
if((dj.getVersion()!=null)&&(dj.getVersion().compareTo("Version
1")==0)){
drl2 = converter.compile( "/reglaVersion1.xls",
InputType.XLS );
builder.addPackageFromDrl( new StringReader( drl2 ) );
}
Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}
When I run the program, the following error message appear:
org.drools.compiler.PackageBuilder$PackageMergeException: Can't merge
packages with different names. This package: com.ReglaPrincipal - New
package: com.reglaVersion1
at org.drools.compiler.PackageBuilder.validatePackageName(PackageBuilder.java:325)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:236)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
Can I work with severals xls files?
--
Lic. Vanina Beraudo
17 years, 11 months
problems with decition tables
by Vanina Beraudo
Hi,
I am working with decition tables, I have differents xls files with
rules and I want to add multiple xls files to the same rulebase and
they will be merged into a single package.
I do the following:
private static RuleBase readTablaDecision() throws Exception {
//read in the source
final SpreadsheetCompiler converter = new SpreadsheetCompiler();
final String drl = converter.compile( "/reglaPrincipal.xls",
InputType.XLS );
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new StringReader( drl ) );
final String drl2, drl3;
if((dj.getVersion()!=null)&&(dj.getVersion().compareTo("Version 1")==0)){
drl2 = converter.compile( "/reglaVersion1.xls", InputType.XLS );
builder.addPackageFromDrl( new StringReader( drl2 ) );
}
Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}
When I run the program, the following error message appear:
org.drools.compiler.PackageBuilder$PackageMergeException: Can't merge
packages with different names. This package: com.ReglaPrincipal - New
package: com.reglaVersion1
at org.drools.compiler.PackageBuilder.validatePackageName(PackageBuilder.java:325)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:236)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
Can I work with severals xls files?
--
Lic. Vanina Beraudo
17 years, 11 months
generic properties
by thomas kukofka
Hello,
I want to use a generic Input-Object for drools which can i.g. access String
properties:
private HashMap<Parameter, String> stringParameter;
with methods:
public String getStringPropertyValue(Parameter parameter) {
return stringParameter.get(parameter);
}
public void setStringPropertyValue(Parameter parameter, String value) {
stringParameter.put(parameter, value);
}
My problem is can I use in drl something like :
when
io: InputObject (getStringPropertyValue("propertyname") == "something")
regards
thomas
17 years, 11 months
RE: [rules-users] How to check for a variable number of "conditions" ina rule?
by Ron Kneusel
Mike,
I think the collect will work, I'll have to look at it more closely because the ordering of elements in the array is significant so I'm not sure I can just break the elements up into facts and let collect group them however it will.
As a follow up, while my solution of using a global in the LHS works, is the problem with changing the global simply that the engine will not see the changes? For my case, the global is set before the rules engine is called and it will not change while the engine runs.
Ron
Mike wrote:
>Have a look at the "Alarms" example for "Collect" in the (4.0.5) manual.
>
>This should give you a good starting point.
>
>Cheers,
>
>Mike
_________________________________________________________________
With Windows Live for mobile, your contacts travel with you.
http://www.windowslive.com/mobile/overview.html?ocid=TXT_TAGLM_WL_mobile_...
17 years, 11 months
InvalidClassException: When creating RuleAgent
by Felbecker, Tobias
When I create a new RuleAgent with a package created with the BRMS
following Exception is thrown:
RuleAgent(BusinessRuleEngine) INFO (Wed Jul 23 12:00:32 CEST 2008):
Configuring with newInstance=true, secondsToRefresh=30
RuleAgent(BusinessRuleEngine) INFO (Wed Jul 23 12:00:32 CEST 2008):
Configuring package provider : FileScanner scanning:
D:\...\mypackage.pkg
RuleAgent(BusinessRuleEngine) EXCEPTION (Wed Jul 23 12:00:33 CEST 2008):
org.drools.base.mvel.DroolsMVELFactory; Serializable incompatible with
Externalizable. Stack trace should follow.
java.io.InvalidClassException: org.drools.base.mvel.DroolsMVELFactory;
Serializable incompatible with Externalizable
...
It works fine with another package created earlier. So it could be
something wrong with my fact model.
I couldn't find any useful information about the Serializeable
incompatible with Externalizable on the web.
17 years, 11 months