Hello,
first of all, I think DocumentHelper.parseText(post) isn't good way
how to parse XML – it internally wraps text with StringReader and
parse text from Reader. So if you have input in form of InputStream or
Reader, it is better to parse XML from this.

Secondly, DOM4J 1.x doesn't work the best in multithreaded
environment. For example, there is single QName cache synchronized
over all threads – so only one thread can use it at a time.

Thirdly, dom4j 1.x uses ArrayList for nodes storage, which is not
efficient in DOM building time – ArrayList must grow repeatedly.

Both synchronization and ArrayList storage should be altered in 2.0 branch.

Regards

Filip Jirsák

2009/2/26 rama <rama.r...@tiscali.it>:
> Hello!
>
>
> I want to have some idea about a performance issue that i am having
> on my application.
>
>
> Basically, what the application do, is a sort of webserver, used to
> parse POST xml request.
>
> For that reason i have a NIO http ws, based on grizzly library, and
> for xml handling i use dom4j
>
> the parsing is done via
> req = DocumentHelper.parseText(post).getRootElement();
>
>
> The design is more or less the follow
> ---SELECTOR THREAD (NIO)---
>    ---READ THREAD1---
>    --READ THREAD2---
> (this 2 reader thread will increase the performance under heavy load)
> then, there is an executor thread pool, that have a MIN and MAX
> worker thread.
> When a selector is readed, and is ready to be executed, it will be
> passed to a "worker" thread, and the worker thread
> will do the rest.
>
> Basically all the parsing logic is on worker threads, the rest is
> just NIO stuff and HTTP protocol stuff, to worker thread, there is a
> REQUEST and RESPONSE
> object, ready for use.
>
> While profiling the code, to make sure that everything is ok, i
> noticed that 90% of the time is spent by
> Element req = DocumentHelper.parseText(post).getRootElement();
>
> which is actually pretty high :S
>
> Also, seems that there is some locking around the code, because two
> different WORKER thread have a lock
> on req = DocumentHelper.parseText(post).getRootElement();
>
> Can you please give to me some advice to increase the performance of
> parsing?
>
> Maybe i can create something in the workerthread to avoid locking?
>
> When i get the Element req, processing it is blazing fast, using some
> "setattribute, getattribute" or even some iteration.
>
> The string size, is normally very very small, never more than 1k,
> often less than 100 char
>
> best regards!
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> dom4j-user mailing list
> dom4j-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>



-- 
Filip Jirsák
fi...@jirsak.org

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to