Re: [xml] libxml2 very slow on big data dump

Stefan Behnel a écrit :
Alexandre Macard wrote:
Stefan Behnel a écrit :
Alexandre Macard wrote:
I try dump a node from a big xml (near 7mo), and the libxml2 is very
slow to respond.

I tried to trace the problem and it seems to take all it's time into
function: xmlOutputBufferWriteEscape.
I do not need to escape data because I use a base64 encoding.

You didn't write which version of libxml2 you are using, but there was a
bug in an older version that could lead to horrible performance when
serialising character entities.

Try upgrading your library.
Sorry I forgot to precise this information. I am using the last version

So maybe it's a similar bug, but for a different encoding (I think it was
related to the ASCII encoding at the time).

Could you provide the code snippet that you use for serialisation? I.e.
what parameters you pass into what function?


This little test code make 15secs to exit.
The journal.xml size is 7.1Mo.

int main() {
    xmlDocPtr doc;
    xmlNodePtr cur;
    xmlBufferPtr buf;

    doc = xmlParseFile("./journal.xml");
    if (doc == NULL ) {
        fprintf(stderr,"Document not parsed successfully. \n");
        return (0);
    cur = xmlDocGetRootElement(doc);

    if (cur == NULL) {
        fprintf(stderr,"empty document\n");
        return (0);

    buf = xmlBufferCreate();
    xmlNodeDump(buf, doc, cur, 1, 1);


    return (0);

I will try to add later a script to generate a similar xml.


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