On Sat, Feb 21, 2009 at 09:29:49AM -0500, Christopher R. Palmer wrote:
> In recent libxml2 code (I saw it when we moved from 2.6.32 to 2.7.2), the 
> xmlBuffer object used by xmlAllocOutputBuffer changed from using the DOUBLEIT 
> allocator to the EXACT allocator.  This ends up being used in 
> xsltSaveResultToString.
> 
> We found that the time to save a node to a string (6MB) went from about 1 
> second to about 13 seconds on a Windows installation.
> 
> I've attached a tiny patch that solves the issue for us.

  Okay I think it relates to this change:

Sat Aug 30 14:50:16 CEST 2008 Daniel Veillard <[email protected]>

        * include/libxml/tree.h tree.c: make a new kind of buffer where
          shrinking and adding in head can avoid reallocation or full
          buffer memmoves
        * encoding.c xmlIO.c: use the new kind of buffers for output
          buffers
and also

Mon Sep  1 15:02:05 CEST 2008 Daniel Veillard <[email protected]>

        * xmlIO.c HTMLtree.c: new internal entry point to hide even
        * better
          xmlAllocOutputBufferInternal
        * tree.c: harden the code around buffer allocation schemes

 What you're seeing is at the intersection of this, where I tried to
avoid a lot of in-memory moves in edge cases and the long identified
but apparently still there problem of the realloc() performances on Windows.
 To be sure the change to DOUBLEIT should only be done if the value is
EXACT, and not any of the other values.
 Can you check the enclosed path instead ?

  thanks,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
[email protected]  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
Index: xmlIO.c
===================================================================
--- xmlIO.c     (revision 3817)
+++ xmlIO.c     (working copy)
@@ -2278,6 +2278,10 @@ xmlAllocOutputBuffer(xmlCharEncodingHand
        return(NULL);
     }
 
+    /* try to avoid a performance problem with Windows realloc() */
+    if (ret->buffer->alloc == XML_BUFFER_ALLOC_EXACT)
+        ret->buffer->alloc = XML_BUFFER_ALLOC_DOUBLEIT;
+
     ret->encoder = encoder;
     if (encoder != NULL) {
         ret->conv = xmlBufferCreateSize(4000);
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to