Re: [rules-dev] [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage
by Greg Barton
Here's a diff for the minimal change I think fixes the problem:
Index: src/main/java/org/drools/common/DefaultAgenda.java
===================================================================
--- src/main/java/org/drools/common/DefaultAgenda.java (revision 35727)
+++ src/main/java/org/drools/common/DefaultAgenda.java (working copy)
@@ -1048,10 +1048,10 @@
boolean fired = fireNextItem( agendaFilter );
fired = fired || !((AbstractWorkingMemory) this.workingMemory).getActionQueue().isEmpty();
this.workingMemory.executeQueuedActions();
- if ( !fired && !missedNotifyAll.get()) {
+ if ( !fired ) {
try {
synchronized ( this.halt ) {
- this.halt.wait();
+ if(!missedNotifyAll.get()) this.halt.wait();
}
} catch ( InterruptedException e ) {
this.halt.set( true );
Basically, move the missedNotifyAll check immediately before the wait. This still avoids the race condition, and only causes one spurious trip through the fireUntilHalt loop on startup. I'd open a JIRA with this in it but I need to get to sleep. :)
--- On Tue, 10/26/10, Greg Barton <greg_barton(a)yahoo.com> wrote:
> From: Greg Barton <greg_barton(a)yahoo.com>
> Subject: Re: [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage
> To: "Rules Users List" <rules-users(a)lists.jboss.org>, rules-dev(a)lists.jboss.org
> Date: Tuesday, October 26, 2010, 1:01 AM
> The problem is the race condition fix
> introduced in rev 30163. The missedNotifyAll flag is
> set to true immediately which causes the busy loop.
> missedNotifyAll is initialized to false, but is immediately
> set to true because notifyHalt() is called in
> AbstractWorkingMemory.queueWorkingMemoryAction() via
> ReteooRuleBase.newStatefulSession(). Anyway, I'll move
> discussions of possible solutions over to the dev list,
> (crossposting now) or a JIRA if you'd prefer that.
>
> --- On Mon, 10/25/10, Greg Barton <greg_barton(a)yahoo.com>
> wrote:
>
> > From: Greg Barton <greg_barton(a)yahoo.com>
> > Subject: Re: [rules-users] Starting engine using
> fireUntilHalt and inserting no facts results in 50% CPU
> usage
> > To: "Rules Users List" <rules-users(a)lists.jboss.org>
> > Date: Monday, October 25, 2010, 3:18 PM
> > I was going to look at this at some
> > point. I guess that point will be tonight. :)
> >
> > GreG
> >
> > On Oct 25, 2010, at 15:02, Edson Tirelli <tirelli(a)post.com>
> > wrote:
> >
> > No worries, it is a good starting point anyway.
> > Hopefully someone
> > can continue from there or I will eventually fix it.
> Just a
> > lot of
> > stuff in my plate already that have priority over
> this.
> >
> > Edson
> >
> > 2010/10/25 mardo <mardo(a)abicola.de>:
> > Unfortunately no, I just had a look how it was
> implemented
> > (like
> > http://tutorials.jenkov.com/java-concurrency/thread-signaling.html#missedsig
> > nals) -> missed signals and noticed that it
> somehow
> > didn't work as intended.
> >
> > But no idea how to directly correct it, sorry.
> >
> > -----Original Message-----
> > From: rules-users-bounces(a)lists.jboss.org
> > [mailto:rules-users-bounces@lists.jboss.org]
> > On Behalf Of Edson Tirelli
> > Sent: Montag, 25. Oktober 2010 21:30
> > To: Rules Users List
> > Subject: Re: [rules-users] Starting engine using
> > fireUntilHalt and inserting
> > no facts results in 50% CPU usage
> >
> > Do you have a solution/patch for it?
> >
> > Edson
> >
> > 2010/10/25 mardo <mardo(a)abicola.de>:
> > Luckily just stumbled upon this mail...
> >
> > You can take a look at
> >
> > http://drools-java-rules-engine.46999.n3.nabble.com/fireUntilHalt-and-OSGi-C
> > PU-load-td1022352.html
> >
> > where I already provided a minimal example (don't know
> if
> > it covers all
> > cases) and tracked it down to missedNotifyAll in
> > DefaultAgenda
> >
> > cheers
> >
> >
> >
> > -----Original Message-----
> > From: rules-users-bounces(a)lists.jboss.org
> > [mailto:rules-users-bounces@lists.jboss.org]
> > On Behalf Of Edson Tirelli
> > Sent: Montag, 25. Oktober 2010 21:17
> > To: Rules Users List
> > Subject: Re: [rules-users] Starting engine using
> > fireUntilHalt and
> > inserting
> > no facts results in 50% CPU usage
> >
> > This is clearly a regression as Drools should be
> not be
> > using busy
> > waits in fireUntilHalt(). It should use monitors and
> locks
> > as it was
> > doing before.
> >
> > Can anyone open a JIRA? also, if anyone would be
> willing
> > to take
> > investigate and fix this one, it would really help.
> > Otherwise, I will
> > add it to my queue.
> >
> > Thanks,
> >
> > Edson
> >
> > 2010/10/25 Norman C <rent_my_time(a)yahoo.com>:
> >
> >
> > Note that the 100% CPU issue with fireUntiHalt is only
> with
> > the 5.1
> > version of
> > Drools. In 5.0.x, CPU is close to 0% when there are
> > no rules to fire. I
> > saw
> > this when I was testing upgrading to 5.1.
> >
> > Norman
> >
> >
> >
> > ----- Original Message ----
> > From: jschmied <nabble(a)juergenschmied.de>
> > To: rules-users(a)lists.jboss.org
> > Sent: Sun, October 24, 2010 4:06:02 AM
> > Subject: Re: [rules-users] Starting engine using
> > fireUntilHalt and
> > inserting no
> > facts results in 50% CPU usage
> >
> >
> > Hi!
> >
> > fireUntilHalt uses one processor with 100%. You have
> a
> > dualcore, so it's
> > 50%. It's by design like this.
> >
> > You can:
> > - Call fireAllRules after every insert if you have no
> > ruleflow.
> >
> > - Use fireAllRules in a loop with a small sleep and
> check
> > for the end of
> > the
> > ruleflow in the loop:
> >
> > while (prc.getState() == ProcessInstance.STATE_ACTIVE)
> {
> > Threads.sleep(20);
> > ksession.fireAllRules();
> > }
> >
> > with both methods you get a low cpu load.
> >
> > bye
> >
> > juergen
> > --
> > View this message in context:
> >
> >
> > http://drools-java-rules-engine.46999.n3.nabble.com/Starting-engine-using-fi
> >
> >
> reUntilHalt-and-inserting-no-facts-results-in-50-CPU-usage-tp1760370p1761821
> > .html
> >
> > Sent from the Drools - User mailing list archive at
> > Nabble.com.
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >
> > --
> > Edson Tirelli
> > JBoss Drools Core Development
> > JBoss by Red Hat @ www.jboss.com
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >
> > --
> > Edson Tirelli
> > JBoss Drools Core Development
> > JBoss by Red Hat @ www.jboss.com
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >
> > --
> > Edson Tirelli
> > JBoss Drools Core Development
> > JBoss by Red Hat @ www.jboss.com
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
>
>
>
14 years, 1 month
Re: [rules-dev] [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage
by Greg Barton
The problem is the race condition fix introduced in rev 30163. The missedNotifyAll flag is set to true immediately which causes the busy loop.
missedNotifyAll is initialized to false, but is immediately set to true because notifyHalt() is called in AbstractWorkingMemory.queueWorkingMemoryAction() via ReteooRuleBase.newStatefulSession(). Anyway, I'll move discussions of possible solutions over to the dev list, (crossposting now) or a JIRA if you'd prefer that.
--- On Mon, 10/25/10, Greg Barton <greg_barton(a)yahoo.com> wrote:
> From: Greg Barton <greg_barton(a)yahoo.com>
> Subject: Re: [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage
> To: "Rules Users List" <rules-users(a)lists.jboss.org>
> Date: Monday, October 25, 2010, 3:18 PM
> I was going to look at this at some
> point. I guess that point will be tonight. :)
>
> GreG
>
> On Oct 25, 2010, at 15:02, Edson Tirelli <tirelli(a)post.com>
> wrote:
>
> No worries, it is a good starting point anyway.
> Hopefully someone
> can continue from there or I will eventually fix it. Just a
> lot of
> stuff in my plate already that have priority over this.
>
> Edson
>
> 2010/10/25 mardo <mardo(a)abicola.de>:
> Unfortunately no, I just had a look how it was implemented
> (like
> http://tutorials.jenkov.com/java-concurrency/thread-signaling.html#missedsig
> nals) -> missed signals and noticed that it somehow
> didn't work as intended.
>
> But no idea how to directly correct it, sorry.
>
> -----Original Message-----
> From: rules-users-bounces(a)lists.jboss.org
> [mailto:rules-users-bounces@lists.jboss.org]
> On Behalf Of Edson Tirelli
> Sent: Montag, 25. Oktober 2010 21:30
> To: Rules Users List
> Subject: Re: [rules-users] Starting engine using
> fireUntilHalt and inserting
> no facts results in 50% CPU usage
>
> Do you have a solution/patch for it?
>
> Edson
>
> 2010/10/25 mardo <mardo(a)abicola.de>:
> Luckily just stumbled upon this mail...
>
> You can take a look at
>
> http://drools-java-rules-engine.46999.n3.nabble.com/fireUntilHalt-and-OSGi-C
> PU-load-td1022352.html
>
> where I already provided a minimal example (don't know if
> it covers all
> cases) and tracked it down to missedNotifyAll in
> DefaultAgenda
>
> cheers
>
>
>
> -----Original Message-----
> From: rules-users-bounces(a)lists.jboss.org
> [mailto:rules-users-bounces@lists.jboss.org]
> On Behalf Of Edson Tirelli
> Sent: Montag, 25. Oktober 2010 21:17
> To: Rules Users List
> Subject: Re: [rules-users] Starting engine using
> fireUntilHalt and
> inserting
> no facts results in 50% CPU usage
>
> This is clearly a regression as Drools should be not be
> using busy
> waits in fireUntilHalt(). It should use monitors and locks
> as it was
> doing before.
>
> Can anyone open a JIRA? also, if anyone would be willing
> to take
> investigate and fix this one, it would really help.
> Otherwise, I will
> add it to my queue.
>
> Thanks,
>
> Edson
>
> 2010/10/25 Norman C <rent_my_time(a)yahoo.com>:
>
>
> Note that the 100% CPU issue with fireUntiHalt is only with
> the 5.1
> version of
> Drools. In 5.0.x, CPU is close to 0% when there are
> no rules to fire. I
> saw
> this when I was testing upgrading to 5.1.
>
> Norman
>
>
>
> ----- Original Message ----
> From: jschmied <nabble(a)juergenschmied.de>
> To: rules-users(a)lists.jboss.org
> Sent: Sun, October 24, 2010 4:06:02 AM
> Subject: Re: [rules-users] Starting engine using
> fireUntilHalt and
> inserting no
> facts results in 50% CPU usage
>
>
> Hi!
>
> fireUntilHalt uses one processor with 100%. You have a
> dualcore, so it's
> 50%. It's by design like this.
>
> You can:
> - Call fireAllRules after every insert if you have no
> ruleflow.
>
> - Use fireAllRules in a loop with a small sleep and check
> for the end of
> the
> ruleflow in the loop:
>
> while (prc.getState() == ProcessInstance.STATE_ACTIVE) {
> Threads.sleep(20);
> ksession.fireAllRules();
> }
>
> with both methods you get a low cpu load.
>
> bye
>
> juergen
> --
> View this message in context:
>
>
> http://drools-java-rules-engine.46999.n3.nabble.com/Starting-engine-using-fi
>
> reUntilHalt-and-inserting-no-facts-results-in-50-CPU-usage-tp1760370p1761821
> .html
>
> Sent from the Drools - User mailing list archive at
> Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
> Edson Tirelli
> JBoss Drools Core Development
> JBoss by Red Hat @ www.jboss.com
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
> Edson Tirelli
> JBoss Drools Core Development
> JBoss by Red Hat @ www.jboss.com
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
> Edson Tirelli
> JBoss Drools Core Development
> JBoss by Red Hat @ www.jboss.com
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
14 years, 1 month
Parser changes in trunk (for the next version)
by Edson Tirelli
All,
Just a heads up for those using trunk. One of our main goals (from a
drools core perspective) for the next Drools version is to improve
consistency of the language and avoid some odd behaviors we had so
far, reducing users' surprises: e.g., add support to 100% of java
syntax for expressions, including things like generics; and avoid
different syntax when using java vs mvel, specially for constraints
that fall back to MVEL.
As a result of this effort, there will be some changes to the DRL
language spec that might make your Drools 5.x DRL incompatible with
the next Drools version. Some are simple things, like the use of "||"
and "&&" between patterns that was deprecated (but still supported)
since Drools 4, but is now being completely removed and you must use
"or" and "and" respectively in between patterns. Some things are more
complicated.
To help users that are migrating from Drools 5.1 to the next
version, we will keep the (now) old DRL parser (just renamed as
DRL5x.g) and will provide a migration tool that uses this parser to
translate an old DRL to the new syntax. This is a one time conversion
that you will have to apply to your source DRL files when migrating
from Drools 5.1 to the next version.
I will commit the first cut of the new grammar later today into
trunk, so be advised that if you face errors after moving to a new
snapshot, it might have been caused by that. Please let me know if
that is the case and the migration tool fails to properly upgrade your
DRL. I will provide the link the migration tool documentation when I
commit the changes.
Let me know if you have any questions.
Edson
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com
14 years, 1 month
CommandFactory: static or ...?
by Wolfgang Laun
All factory methods are static except newInsertElements with 4 args.
Since there's absolutely no reason for this annoying outlier I have added
static and commited in trunk.
-W
14 years, 1 month
Use of java.util.logging.Logger in JPAVariablePersister
by Antoine Toulme
Hi,
I thought Drools was standardizing over slf4j. Is there a reason why a
java.util.logging.Logger class is used ?
Here is some of the code:
Logger.getLogger(JPAVariablePersister.class.getName()).log(Level.SEVERE,
null, t);
Should slf4j be used instead ? Note it's used by JtaTransactionManager and
SingleSessionCommandService in the same project.
Thanks,
Antoine
14 years, 1 month
Re: [rules-dev] KnowledgeAgent: Unable to find implementation for BusinessRuleProvider
by esteban.aliverti@gmail.com
As far as i know, Brl syntax is kind of "deprecated". Only guvnor should use
it. I can add support for brl easily, but i don't know if this is correct or
not. Guys? What is your opinion?
El oct 21, 2010 5:46 p.m., "drhookson" <hugo(a)koblmueller.com> escribió:
hi.all,
I working with drools-5.1.1 and just wanted to change my working
knowledgeagent version, which pulls the package binary from the guvnor, to
use local stored BRL files.
As for what I assumed that the KnowledgeAgent is aware of the different
resource types, I simply exchanged in the change-set.xml the resource
location and type specification accordingly to the BRL ones, like the
following:
String ruleFile =
"file://Projects/Workspace/myProject/src/rules/DeadManSwitch.brl";
String xml = "";
xml += "<change-set
xmlns='http://drools.org/drools-5.0/change-set'";
xml += "
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
xml += "
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...
'
>";
xml += " <add>";
xml += " <resource source='" + ruleFile + "'
type='BRL'/>";
xml += " </add>";
xml += "</change-set>";
All the other things like setting up the KnowledgeAgent, applying the change
set, a.s.o remained the same, but when executing the program I get the
following exception reported:
SEVERE: Run exception: java.lang.RuntimeException:
org.drools.compiler.DroolsParserException:
org.drools.CheckedDroolsException: Unable to find implementation for
BusinessRuleProvider
Stack trace:
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:544)
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:637)
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:889)
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:704)
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:584)
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:185)
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168)
Any idea what am I missing here?
thx
-hugo
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/KnowledgeAgent-Unable...
Sent from the Drools - Dev mailing list archive at Nabble.com.
_______________________________________________
rules-dev mailing list
rules-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
14 years, 1 month
Parameterized Evaluator Definition using \u2282 as parameter
by Wolfgang Laun
Well, yes, I'm naughty. I've implemented a parameterized evaluator, using
Unicode codepoint
U+2282<http://www.fileformat.info/info/unicode/char/2282/index.htm>as
a parameter.
But the DRL parser refuses to accept this (as part of square_chunk_data):
Line 60:59 no viable alternative at input ''
which indicates that the character isn't recognized at all.
I think this happens because, outside of strings, codepoints beyond U+007F
aren't accepted anywhere except
those explicitly specified as IdentifierStart and IdentifierPart. Perhaps
square_chunk_data after an operator
identifier could be made to behave more like a string.
Admittedly, this is esoteric, but it sure does look dazzling ;-)
Cheers
-W
14 years, 1 month
KnowledgeAgent: Unable to find implementation for BusinessRuleProvider
by drhookson
hi.all,
I working with drools-5.1.1 and just wanted to change my working
knowledgeagent version, which pulls the package binary from the guvnor, to
use local stored BRL files.
As for what I assumed that the KnowledgeAgent is aware of the different
resource types, I simply exchanged in the change-set.xml the resource
location and type specification accordingly to the BRL ones, like the
following:
String ruleFile =
"file://Projects/Workspace/myProject/src/rules/DeadManSwitch.brl";
String xml = "";
xml += "<change-set
xmlns='http://drools.org/drools-5.0/change-set'";
xml += "
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'";
xml += "
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...'
>";
xml += " <add>";
xml += " <resource source='" + ruleFile + "'
type='BRL'/>";
xml += " </add>";
xml += "</change-set>";
All the other things like setting up the KnowledgeAgent, applying the change
set, a.s.o remained the same, but when executing the program I get the
following exception reported:
SEVERE: Run exception: java.lang.RuntimeException:
org.drools.compiler.DroolsParserException:
org.drools.CheckedDroolsException: Unable to find implementation for
BusinessRuleProvider
Stack trace:
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:544)
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:637)
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:889)
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:704)
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:584)
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:185)
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168)
Any idea what am I missing here?
thx
-hugo
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/KnowledgeAgent-Unable...
Sent from the Drools - Dev mailing list archive at Nabble.com.
14 years, 1 month