You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Cezar Andrei <ce...@oracle.com> on 2010/06/09 19:54:51 UTC

RE: Bad performance using multiple threads

Choel,

There are two types of locks in XMLBeans: 
 - a global lock that is used only on operations involving two documents in different locales are used
 - a local lock, per locale, by default each new doc gets its locale, using options same locale can be used for more docs)

Even for read operations because it involves state, there is a need for a lock to be used.

But for your case, which seems so performance oriented, if you know what you do, you can try using unsynchronized documents (use option when creating your doc), but you need to handle the synchronization separately.

Cezar

-----Original Message-----
From: choel [mailto:choel@gmx.de] 
Sent: Wednesday, May 26, 2010 12:29 PM
To: user@xmlbeans.apache.org
Subject: Bad performance using multiple threads


Hi,

to improve the performance I started parallelizing (simple fork and join)
some tasks.
After testing the correctness of the output I found the performance on the
parallel tasks extremely bad.
In my testcase it is actually 4 times slower as normal single threaded
usage. I am using a standard dual core cpu running two threads parallel.
Is there anything known on bad multithreading performance using xmlbeans? In
my case there is a lot parallel reading on the same data. Readlocks are for
my usage not neccessary.
Thanks in advance for some help.

Here is some performance data:
1 Thread on dual core:
Creating graph with 2407 nodes, took: 375 ms
Routing 3170 connections, took: 31610 ms

4 Threads on dual core:
Creating graph with 601 nodes, took: 250 ms
Creating graph with 601 nodes, took: 266 ms
Creating graph with 604 nodes, took: 282 ms
Creating graph with 601 nodes, took: 282 ms
Routing 794 connections, took: 57172 ms
Routing 792 connections, took: 59625 ms
Routing 792 connections, took: 60469 ms
Routing 792 connections, took: 60485 ms

Bye Claus

-- 
View this message in context: http://old.nabble.com/Bad-performance-using-multiple-threads-tp28683839p28683839.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Bad performance using multiple threads

Posted by choel <ch...@gmx.de>.
Hi Cezar,

thanks for your reply.
Yesterday I had a closer look into the xmlbean sources and the generated
classes.
I made a small experiment, changing the code generator such that it skipped
the "synchronized(monitor()) part and some other minor changes. The result
was the expected performance boost. This worked of course only for my
special case, where cursors etc. do not get upset by mutliple threads.
Looking at the xmlbean code that handles the data, the architecture does not
seem to support an easy way to make xmlbeans useable for multithreading by
finely grained locking mechanisms. Today its is a "nailed monolith".
The future of CPU's will surely be a massive multi core architecture,
therefore gaining performance by parallel programming. The new java versions
support concurrency quite well - the next version will include parallel
arrays etc.. 
Is it in your focus to upgrade xmlbeans to post java 1.4? If so it would be
nice beginning to support parallel programming.
My clean workaround for now is creating XmlObjects seperatly, work on them
parallel (with there own locale) and add them late as a list to the main
document. This is possible for some usecases.
Anyway, xmlbeans is a very good tool, working now 6 years with it - thanks
to the great work of the development team.

Bye Claus


Cezar Andrei-3 wrote:
> 
> Choel,
> 
> There are two types of locks in XMLBeans: 
>  - a global lock that is used only on operations involving two documents
> in different locales are used
>  - a local lock, per locale, by default each new doc gets its locale,
> using options same locale can be used for more docs)
> 
> Even for read operations because it involves state, there is a need for a
> lock to be used.
> 
> But for your case, which seems so performance oriented, if you know what
> you do, you can try using unsynchronized documents (use option when
> creating your doc), but you need to handle the synchronization separately.
> 
> Cezar
> 
> -----Original Message-----
> From: choel [mailto:choel@gmx.de] 
> Sent: Wednesday, May 26, 2010 12:29 PM
> To: user@xmlbeans.apache.org
> Subject: Bad performance using multiple threads
> 
> 
> Hi,
> 
> to improve the performance I started parallelizing (simple fork and join)
> some tasks.
> After testing the correctness of the output I found the performance on the
> parallel tasks extremely bad.
> In my testcase it is actually 4 times slower as normal single threaded
> usage. I am using a standard dual core cpu running two threads parallel.
> Is there anything known on bad multithreading performance using xmlbeans?
> In
> my case there is a lot parallel reading on the same data. Readlocks are
> for
> my usage not neccessary.
> Thanks in advance for some help.
> 
> Here is some performance data:
> 1 Thread on dual core:
> Creating graph with 2407 nodes, took: 375 ms
> Routing 3170 connections, took: 31610 ms
> 
> 4 Threads on dual core:
> Creating graph with 601 nodes, took: 250 ms
> Creating graph with 601 nodes, took: 266 ms
> Creating graph with 604 nodes, took: 282 ms
> Creating graph with 601 nodes, took: 282 ms
> Routing 794 connections, took: 57172 ms
> Routing 792 connections, took: 59625 ms
> Routing 792 connections, took: 60469 ms
> Routing 792 connections, took: 60485 ms
> 
> Bye Claus
> 
> -- 
> View this message in context:
> http://old.nabble.com/Bad-performance-using-multiple-threads-tp28683839p28683839.html
> Sent from the Xml Beans - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Bad-performance-using-multiple-threads-tp28683839p28968499.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org