[xml] First experiments with threading



  I integrated Gary's patches, and started doing some tests.
I built the library with and without threading on Linux and used
xmllint, i.e. an application with a single thread to test side
effects and evaluate the impact on performances:

   the test is to parse (and possibly validate) the XML spec 100 times
     xmllint --noout --repeat test/XML/test/valid/REC-xml-19980210.xml
   and
     xmllint --valid --noout --repeat test/XML/test/valid/REC-xml-19980210.xml

            Non threaded            Threaded

normal      3720ms                  5857ms
valid       6712ms                  9781ms

  I made the tests on an SMP box running Linux Red Hat with 2.4.7 kernel.
I think the impact comes from the access to the memory routines, libxml
is extremely aggressive on the memory allocator, and in the current code
the xmlMalloc/xmlRealloc/xmlFree are part of the per-thread data. This
mean that we are currently calling pthread_self() in addition to the
existing routine each time we access them and this reflects on performances.

  My current view are:
   1/ that threaded mode should not be the default configuration
   2/ that by default xmlMalloc/xmlRealloc/xmlFree should be kept
      application wide settings
   3/ that it shall be relatively straightforward to make them
      thread specific with the use of a dedicated #define
      this can still be useful for other thread models the
      equivalent of pthread_self() is real cheap.
 
 However I remember getting mail asking "per thread" allocator
so that one could build an zero cost deallocator, and clearly
this is not a good idea. I turned down the request at that point
and now I have data to back up my position :-)

  I will work on 2/ to check if my analysis of the added cost was right,
and will do 3/ if it is confirmed. Then I will cleanup the couple of places
where libxml code need locking and add some threading regression tests.

tests

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]