[rules-users] Multi-threading inefficiency caused by static class synchronization?

Mauricio Salatino salaboy at gmail.com
Tue Dec 11 04:22:36 EST 2012


You can also split your application in multiple processes to use multiple
JVMs. if you have 8 threads it can be divided into starting two apps with 4
threads each. If you are working with Stateless session that shouldn't be a
problem.
Cheers


On Tue, Dec 11, 2012 at 7:23 AM, Wolfgang Laun <wolfgang.laun at gmail.com>wrote:

> Looking at the code of the thread you are running in parallel
> I guess that almost all of its time is spent in session creation,
> and during this (and the dispose) the knowledge base is a
> resource that needs protection. Thus, the test you are running
> isn't well suited for demonstrating concurrency.
>
> * Run one stateful session per thread, inserting and retracting
> (random) facts.
> * Add code wasting cycles to your rule(s).
>
> Also, make sure that the global (which is shared between sessions)
> isn't causing another bottleneck.
>
> -W
>
>
> On 11/12/2012, ping <jinpingv at hotmail.com> wrote:
> > I tried profiling my test program and found that all thread spent most of
> > their time blocking or waiting for the same lock:
> >
> org.drools.runtime.process.ProcessRuntimeFactory.getProcessRuntimeFactoryService()
> > and
> > org.drools.common.AbstractRuleBase.lock()
> >
> > examples:
> >
> > Thread-6 [WAITING] CPU time: 1s
> > java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock()
> > org.drools.common.UpgradableReentrantReadWriteLock.lowPriorityWriteLock()
> > org.drools.common.UpgradableReentrantReadWriteLock.writeLock()
> > org.drools.common.AbstractRuleBase.lock()
> > org.drools.impl.StatelessKnowledgeSessionImpl.<init>(InternalRuleBase,
> > KnowledgeAgent, KnowledgeSessionConfiguration)
> > org.drools.impl.KnowledgeBaseImpl.newStatelessKnowledgeSession()
> > java.lang.Thread.run()
> >
> >
> >
> > Thread-7 [BLOCKED] CPU time: 1s
> >
> org.drools.runtime.process.ProcessRuntimeFactory.getProcessRuntimeFactoryService()
> >
> org.drools.runtime.process.ProcessRuntimeFactory.newProcessRuntime(AbstractWorkingMemory)
> > org.drools.common.AbstractWorkingMemory.createProcessRuntime()
> >
> org.drools.common.AbstractWorkingMemory.setKnowledgeRuntime(InternalKnowledgeRuntime)
> > org.drools.impl.StatefulKnowledgeSessionImpl.<init>(ReteooWorkingMemory,
> > KnowledgeBase)
> > org.drools.impl.StatelessKnowledgeSessionImpl.newWorkingMemory()
> > org.drools.impl.StatelessKnowledgeSessionImpl.execute(Object)
> > java.lang.Thread.run()
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://drools.46999.n3.nabble.com/Multi-threading-inefficiency-caused-by-static-class-synchronization-tp4021160p4021163.html
> > Sent from the Drools: User forum mailing list archive at Nabble.com.
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
 - MyJourney @ http://salaboy.wordpress.com
 - Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar

 - Salatino "Salaboy" Mauricio -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20121211/b834a101/attachment-0001.html 


More information about the rules-users mailing list