Re: [rules-users] Jbilling Drools performance
by Greg Barton
See attached project, DroolsBilling.
You can build it with Maven from the project directory: mvn clean package
To run it after building: java -jar target/DroolsBilling-1.0.jar <numRules> <numPhoneNumbersPerThread>
$ java -server -jar target/DroolsBilling-1.0.jar 100 100000Rules load time: 3482msRules execution time: 732ms, per number: 0.00732msRules execution time: 731ms, per number: 0.00731msRules execution time: 746ms, per number: 0.00746msRules execution time: 760ms, per number: 0.0076msRules execution time: 832ms, per number: 0.00832msRules execution time: 623ms, per number: 0.00623msRules execution time: 600ms, per number: 0.0060msRules execution time: 632ms, per number: 0.00632msRules execution time: 630ms, per number: 0.0063msRules execution time: 607ms, per number: 0.00607msDONE!
At higher numbers of rules you have to increase the perm gen and heap memory:
$ java -server -Xmx1024M -XX:MaxPermSize=128M -jar target/DroolsBilling-1.0.jar 10000 100000Rules load time: 58317msRules execution time: 1580ms, per number: 0.0158msRules execution time: 1580ms, per number: 0.0158msRules execution time: 1586ms, per number: 0.01586msRules execution time: 2493ms, per number: 0.02493msRules execution time: 2502ms, per number: 0.02502msRules execution time: 1360ms, per number: 0.0136msRules execution time: 1358ms, per number: 0.01358msRules execution time: 1376ms, per number: 0.01376msRules execution time: 473ms, per number: 0.00473msRules execution time: 489ms, per number: 0.00489msDONE!
As you can see the time to process one phone number is lower than 1 minute. :) The example uses 5 concurrent threads and was executed on a 4 core machine.
A Sample.drl is included that shows the format of the rules generated, basically this:
rule "PhoneNumber000000000" when p : PhoneNumber( digit0 == '0', digit1 == '0', digit2 == '0', digit3 == '0', digit4 == '0', digit5 == '0', digit6 == '0', digit7 == '0', digit8 == '0', digit9 == '0') then p.setPrice(0.0);end
They should be substantially similar to the rules generated behind the decision table you've given, so the performance should be similar. As you can see from the times above, rule creation is expensive but execution is cheap. As Mark said, reuse the KnowledgeBase.
--- On Tue, 5/18/10, Antonio Anderson Souza <antonio(a)voicetechnology.com.br> wrote:
From: Antonio Anderson Souza <antonio(a)voicetechnology.com.br>
Subject: Re: [rules-users] Jbilling Drools performance
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Date: Tuesday, May 18, 2010, 4:11 PM
Greg,
CDR is a Call Detail Record, sorry I forgot to explain it, the object is
a POJO with the following attributes:
field: name: datereference type: DATE value: 2010-04-28 00:00:00.0
field: name: billingid type: STRING value: 20100428.15544.42adf
field: name: accountid type: INTEGER value: 15544
field: name: billingperiod type: STRING value: 20100401
field: name: billingclassification type: STRING value: DUR
field: name: ipxcallguid type: STRING value:
5k692927-guwtka-g8kj8d0u-1-g8krry54-o4n
field: name: transactiondatetime type: DATE value: 2010-04-28
20:21:01.337
field: name: billingitemid type: INTEGER value: 0
field: name: ratesystem type: STRING value: IPXNET
field: name: originnumber type: STRING value:
551135880520(a)bitcompany.braste
field: name: destinationnumber type: STRING value: 551139012650
field: name: destinationareaid type: STRING value: 100000551
field: name: chargedduration type: DATE value: 1980-01-01 00:02:06.0
field: name: chargedamount type: FLOAT value: 0.0816
field: name: userid type: INTEGER value: 3372
field: name: username type: STRING value: bitcom51
field: name: unitamount type: FLOAT value: 0.00389
field: name: amountcurrency type: STRING value: USD
field: name: timezone type: INTEGER value: -3
field: name: registertype type: STRING value: MV
field: name: datelastupdated type: DATE value: 2010-04-29 02:57:18.54
field: name: lastupdatedby type: STRING value: IPXRateCalls rev032
field: name: lastupdateremarks type: STRING value: null
field: name: dateinserted type: DATE value: 2010-04-29 02:57:18.54
field: name: destinationdetail type: STRING value: SAO PAULO
field: name: type type: STRING value: Fixo
field: name: collectedcallflag type: INTEGER value: 0
field: name: jb_timestamp type: DATE value: null
field: name: digit0 type: INTEGER value: 5
field: name: digit1 type: INTEGER value: 5
field: name: digit2 type: INTEGER value: 1
field: name: digit3 type: INTEGER value: 1
field: name: digit4 type: INTEGER value: 3
field: name: digit5 type: INTEGER value: 9
field: name: digit6 type: INTEGER value: 0
field: name: digit7 type: INTEGER value: 1
field: name: digit8 type: INTEGER value: 2
field: name: digit9 type: INTEGER value: 6
field: name: digit10 type: INTEGER value: 5
field: name: digit11 type: INTEGER value: 0
This spreadsheet is only a sample because the whole one has 40000 rules, I'm checking the Jbilling code, but it seams to be loading the rules each time.
Best regards,
Antonio Anderson Souza
Voice Technology
http://www.antonioams.com
2010/5/18 Greg Barton <greg_barton(a)yahoo.com>
OK, so a few questions:
What is a CDR? How much data does it contain? Do you load the rules fresh each time you process one? Are there other rules besides the ones listed in the decision table?
14 years, 6 months
removeKnowledgePackage Call Hangs!!
by malkhafaji
I am trying to unload a KnowledgePackage that is already loaded in my
KnowledgeBase. The call:
this.knowledgeBase.removeKnowledgePackage(knowledgePackage.getName());
hangs (never returns). I had a similar problem with adding a
KnowledgePackage to a KnowledgeBase and someone on here suggested that there
was a synchronization problem in the internal implementation of the add
method in the KnowledgeBase class, and that problem went away when I
downloaded M1 files (from Feburary 10th of this year). However, I just got
to test the removing of the KnowledgePackage and I seem to have a similar
problem (?).
Here is my unload rule:
rule "MyRule 1.0"
when
mpr : MyObject()
eval(mpr.isKnowledgeBaseLoaded("ACTIVE_KP"))
then
mpr.print("Rule MyRule 1.0 Executed");
mpr.removeKnowledgeBase("ACTIVE_KP");
end
The statement "Rule MyRule 1.0 Executed" is printed, and I am able to debug
the code all the way to the line outlined above, and that is when it goes in
a black hole. Any ideas why this is happening? Is this something fixed in
M2? Here is the log:
INFO|11904/0|10-05-13 13:19:54|Exception in thread "Thread-5"
org.drools.runtime.rule.ConsequenceException: rule: MyRule 1.0
INFO|11904/0|10-05-13 13:19:54|
INFO|11904/0|10-05-13 13:19:54| at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)
INFO|11904/0|10-05-13 13:19:54| at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:981)
INFO|11904/0|10-05-13 13:19:54| at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:918)
INFO|11904/0|10-05-13 13:19:54| at
org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1130)
INFO|11904/0|10-05-13 13:19:54| at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:739)
INFO|11904/0|10-05-13 13:19:54| at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:705)
INFO|11904/0|10-05-13 13:19:54| at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:200)
INFO|11904/0|10-05-13 13:19:54| at
com.medcpu.mpu.pp.engine.Drools.fireRules(Drools.java:459)
INFO|11904/0|10-05-13 13:19:54| at
com.medcpu.mpu.MpuExecutor.executeRules(MpuExecutor.java:191)
INFO|11904/0|10-05-13 13:19:54| at
com.medcpu.mpu.MpuExecutor.initiateRuleExecution(MpuExecutor.java:431)
INFO|11904/0|10-05-13 13:19:54| at
com.medcpu.mpu.MpuExecutor.propertyChanged(MpuExecutor.java:147)
INFO|11904/0|10-05-13 13:19:54| at
com.medcpu.mpu.MpuExecutor.run(MpuExecutor.java:498)
INFO|11904/0|10-05-13 13:19:54| at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
INFO|11904/0|10-05-13 13:19:54| at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
INFO|11904/0|10-05-13 13:19:54| at java.lang.Thread.run(Unknown Source)
INFO|11904/0|10-05-13 13:19:54|Caused by: java.lang.NullPointerException
INFO|11904/0|10-05-13 13:19:54| at
org.drools.reteoo.RuleTerminalNode.doRemove(RuleTerminalNode.java:369)
INFO|11904/0|10-05-13 13:19:54| at
org.drools.common.BaseNode.remove(BaseNode.java:95)
INFO|11904/0|10-05-13 13:19:54| at
org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:237)
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/removeKnowledgePackag...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months
Error when Loading New KnowledgeBuilder
by Ken Archer
I just built installed the Drools Eclipse plug-in on a new development machine, and now whenever I load a new KnowledgeBuilder (KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();), the source of PackageBuilderConfiguration.class loads in a new tab with the following lines before the code:
Class File Editor
Source not found
The JAR of this class file belongs to container 'Drools Library' which does not allow modifications to source attachments on its entries.
The default 5.0.1 Drools Runtime jars are in the Drools Library path, just like on my previous development machine. Any thoughts?
Ken Archer
14 years, 6 months
Jbilling Drools performance
by Antonio Anderson Souza
Dear All,
I'm deploying a JBilling using Drools in a Telecom Carrier in Brazil, and
I'm using Decision tables in xls files to execute the pricing, my pricing
table has about 40.000 rules, and I'm getting a terrible performance about
1.5 minute to execute the price of each CDR (Call Detail Record) mediated.
Follow bellow a small piece of my decision table:
*RuleTable Padrao* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
*CONDITION* *CONDITION* *ACTION* *PRIORITY * *PricingField* *
PricingManager* *manager* *salience* name eval (strValue.charAt(0) ==
'$param') eval (strValue.charAt(1) == '$param') eval (strValue.charAt(2) ==
'$param') eval (strValue.charAt(3) == '$param') eval (strValue.charAt(4) ==
'$param') eval (strValue.charAt(5) == '$param') eval (strValue.charAt(6) ==
'$param') eval (strValue.charAt(7) == '$param') eval (strValue.charAt(8) ==
'$param') eval (strValue.charAt(9) == '$param') eval (strValue.charAt(10) ==
'$param') eval (strValue.charAt(11) == '$param') itemId setPrice($param)
Campo Digito1 Digito2 Digito3 Digito4 Digito5 Digito6 Digito7 Digito8
Digito9 Digito10 Digito11 Digito12 ID do Item Preço Ordem destinationnumber
5 5 1 1 3 5 8 8 0 1 8 8 300 0.00000 1 destinationnumber 5 5 1 1 3 5 8 8 0 1
8 7 300 0.00000 2 destinationnumber 5 5 1 1 3 5 8 8 0 1 8 6 300 0.00000 3
destinationnumber 5 5 1 1 3 5 8 8 0 1 8 5 300 0.00000 4 destinationnumber 5
5 1 1 3 5 8 8 0 1 8 4 300 0.00000 5 destinationnumber 5 5 1 1 3 5 8 8 0 1 8
3 300 0.00000 6 destinationnumber 5 5 1 1 3 5 8 8 0 1 8 2 300 0.00000 7
destinationnumber 5 5 1 1
300 0.40000 8
Is it normal? Are there somebody using Jbilling in a similar way? Does
anybody can help me?
Best regards,
Antonio Anderson Souza
Voice Technology
http://www.antonioams.com
14 years, 6 months
Potential Deadlock using fireUntilHalt and signalEvent
by mardo
Hi there,
I am facing the following situation: In a few words, I have the following
separate Threads running:
- a fireUntilHalt() on the StatefulKnowledgeSession --> Thread-1 in the
picture
- a recurrent insertion of events into the knowledge base --> Thread-main in
the picture
- a custom asynchroneous WorkItemHandler, which does some fake work and then
signalizes completion to the flow engine (Threads 3&4 in the picture).
It is often the case that my program runs into a deadlock.
My impression is, that fireUntilHalt() (Thread1) gets the synchronized
monitor on AbstractWorkingMemory.actionQueue in line 1411 , while the
WorkItemManager (Thread3) gets the monitor on NamedEntryPoint in line 120.
When fireUntilHalt() then tries to get the monitor on NamedEntryPoint in
line 260, while the WorkItemManager tries to get the monitor on
AbstractWorkingMemory.actionQueue in line 1411, we have a deadlock.
Please correct me if there is any misunderstanding from my side regarding
the synchronization concepts.
Thanks and best
Markus
14 years, 6 months
How to find ALL active sub/processes for a root process instance?
by tolitius
Having several active processes ( parent + its subprocesses + subprocesses of
the parent subproccesses ):
mysql> select InstanceId, processId, state from processinstanceinfo;
+------------+--------------------------------+-------+
| InstanceId | processId | state |
+------------+--------------------------------+-------+
| 1 | main-flow | 1 |
| 2 | first-level-subprocess-flow | 1 |
| 3 | second-level-subprocess-flow | 1 |
+------------+--------------------------------+-------+
Having a parent process instance ID, how to programmatically (using the out
of the box framework capabilities) find all _active_ subprocesses? [ of all
levels, e.g. including subprocesses of the parent subprocesses ]?
I would think that the answer is:
StatefulKnowledgeSession session =
knowledgeProvider.loadStatefulKnowledgeSession( sessionId );
WorkflowProcessInstance parentProcess = ( WorkflowProcessInstance )
session.getProcessInstance( processInstanceId );
for ( NodeInstance node : parentProcess.getNodeInstances() ) {
.... ... ...
}
But no, it only returns a one level of subprocesses.
So two(2) questions here:
1. How to programmatically, using OTB framework features get them?
2. Why does not processInstance"Info" have "Info" about a sub process,
like a PARENT_ID?
Thank you,
/Anatoly
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-find-ALL-activ...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months
Using Drools as a glorified Hashmap
by djb
Hi Drools users,
I've got a situation where I've got a list of Drug codes which can only be
used for certain prescription codes.
The traditional method for implementing this is to simply pre-load the
values in a static Hashmap. Then if get() returns null, it is not a valid
combination. O(1), blazingly fast.
The issue with using Drools for this, is that Drools can match a code to a
code, and mark it as valid, but cannot call it invalid, as another rule may
still be relevant. Therefore, using Drools for this would require marking
combinations as valid, and afterwards, doing a linear traversal of the
prescriptions to see if there are any combinations that are not valid.
Is this the case? I would like to try implement it in Drools just for the
sake of consistency, but it seems a bit of a hack.
Thanks,
Daniel
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Using-Drools-as-a-glo...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months
Time Taken To Load Rule Resource
by Adeyinka Timi
Hi guys,
I have a drools application running that takes about 7 seconds to run. 5
seconds of this time is used in parsing 2 DRL files that 200kb (6200 lines
of code) and 34kb (1400 lines of code). Do you guys have any tips or any
techniques that I can use to improve performance?
- Ade
14 years, 6 months
Entry-Points can cause NullPointerExceptionand/or no rule firing
by Makewise - Vitor Rui Mendonça
Hi!
Anyone with some other thought about this issue?
I'm running out of ideas...
Best regards,
Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento
Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt <http://www.makewise.pt>
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>
Vitor,
Please stop replying to posts with unrelated topics and just changing the title, it messes up the threaded view in most people's email app. See here for more details on netiquette:
http://www.jboss.org/drools/lists.html <http://www.jboss.org/drools/lists.html>
Mark
On 14/05/2010 15:51, Makewise - Vitor Rui Mendonça wrote:
Hi Greg!
Thanks for your quick answer.
I'm having some trouble with absence of events in Drools (I've send some emails on the mailing list regarding that) and I personally think it's some kind of bug (mine or, probably, drools).
So, I'm looking for some help. Instead of explaining all over again, I just point the issue out.
Sorry about this mess, too much time around this problem J
Thanks, once again!
Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento
Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Greg Barton
Sent: sexta-feira, 14 de Maio de 2010 15:31
To: Rules Users List
Subject: Re: [rules-users] Entry-Points can cause NullPointerExceptionand/or no rule firing
JIRA issues are for reporting bugs in drools. Is there a bug you're reporting or do you want help with this particular problem?
--- On Fri, 5/14/10, Makewise - Vitor Rui Mendonça <Vitor.Mendonca(a)brisa.pt> <mailto:Vitor.Mendonca@brisa.pt> wrote:
From: Makewise - Vitor Rui Mendonça <Vitor.Mendonca(a)brisa.pt> <mailto:Vitor.Mendonca@brisa.pt>
Subject: [rules-users] Entry-Points can cause NullPointerException and/or no rule firing
To: "Rules Users List" <rules-users(a)lists.jboss.org> <mailto:rules-users@lists.jboss.org>
Date: Friday, May 14, 2010, 8:40 AM
Hi again.
First of all, I'm running Drools 5.1.0.SNAPSHOT on Windows and Eclipse 3.4.
I've submitted a Jira Issue (https://jira.jboss.org/jira/browse/JBRULES-2511):
"
I've got a system that receives transactions. I want to implement the following rules:
- raise an alarm(alarm event) when there aren't any transaction for an hour (or more);
- if there's an alarm, no more alarms should be raised;
- if there's an alarm and the system receives a transaction, that alarm should be retracted and the system should send an recovery event.
I've implemented the rules this way:
- ***start*** rule to insert an "EngineStart" event when the rules engine starts
- ***notrx_after_start*** rule to detect absence of transactions during the first hour
- ***notrx_after_trx*** rule to detect absence of transactions (during one hour) after last transaction
- ***rearm*** rule to detect transactions and rearm the system.
I made a Maven project with junits, which inserts transactions at specific time, in order to raise the desired events.
Two set of tests were made:
- the rules defined in "default" entry-point: the correspondent junit gives a NullPointerException in DefaultAgenda
- the rules defined in "incoming" entry-point: the correspondent junit doesn't activate the ***rearm*** rule
"
The issue has an attachment with junits and rules to play with.
T.I.A.
Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento
Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>
-----Inline Attachment Follows-----
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users <https://lists.jboss.org/mailman/listinfo/rules-users>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org <mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users <https://lists.jboss.org/mailman/listinfo/rules-users>
14 years, 6 months
Re: [rules-users] Drools Execution Query
by djb
what i've found is that you should always just make things as easy as
possible for the rule engine.
the RETE graph cannot put 'evaluated' conditions into its graph. it can't
make a graph link because the method could evaluate to anything, and
therefore there is no 'cacheing', though i doubt anything is really cached.
so, if you can, call that method beforehand, and put the boolean result as a
field in your fact object. that will vastly improve the run time.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Execution-Quer...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months