Re: [xml] xmlDocDumpMemory() is VERY slow on Win32




        On MacOSX 10.3.4, 650Mhz G4 Mac (100Mhz system bus):

        gcc -o steve2 steve2.c
        time ./steve2.c

malloc OK (16000)
000: realloc OK (16000 to 32000)
001: realloc OK (32000 to 48000)
002: realloc OK (48000 to 64000)
003: realloc OK (64000 to 80000)
004: realloc OK (80000 to 96000)
<blah>
637: realloc OK (10208000 to 10224000)
638: realloc OK (10224000 to 10240000)
639: realloc OK (10240000 to 10256000)
1 seconds
0.000u 0.020s 0:00.72 2.7%      0+0k 0+0io 0pf+0w


It would be interesting to compare in Windows both Athlon versus Intel chips, as Athlons for example have a different virtual memory paging implementation.


Regards,
                Jose.

--
Arguing with an engineer is like wrestling with a pig in mud.
After a while, you realize the pig is enjoying it.


On 13 Jul 2004, at 16:37, Steve Hay wrote:

OK.  So the first sequence in which the buffer is being doubled is the
xmlReadFile() call, reading in the 10MB file.  The second sequence in
which the buffer is grown by 16000 bytes at a time is what Igor referred to -- and it is indeed approx 640 calls (10MB / 16000bytes) as he predicted.

I now share Igor's bad feeling about this in the light of the following
program:

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <time.h>
void main(void) {
  char *buf;
  int i, size;
  time_t start, end;
  size = 16000;
  if ((buf = malloc(size)) == NULL) {
    printf("malloc failed\n");
    exit(3);
  }
  else {
    printf("malloc OK (%d)\n", size);
  }
  time(&start);
  for (i = 0; i < 640; i++, size += 16000) {
    if ((buf = (char *)realloc(buf, size + 16000)) == NULL) {
      printf("%03d: realloc failed\n", i);
      exit(4);
    }
    else {
      printf("%03d: realloc OK (%d to %d)\n", i, size, size + 16000);
    }
  }
  time(&end);
  free(buf);
  printf("%d seconds\n", end - start);
  exit(0);
}

Could somebody please try this on Linux (well, anything other than Win32
I guess) and tell me how long it takes to run?

On my P4 2GHz Win32 box it takes 15seconds -- exactly the same time as
the XML parsing/dumping earlier!  (And it's just as slow without the
printf() calls in it.)

I dare say the time will be 0 or 1 second on Linux.

My soul is indeed lost :( Where do I go from here? (Don't say Linux...)

- Steve





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