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

Wolfgang Laun wolfgang.laun at gmail.com
Tue Dec 11 02:23:55 EST 2012


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
>


More information about the rules-users mailing list