HI,
I'm using 7.4.5 on Mac OS X (G5) and was profiling it to see why it is
SO SLOW at committing inserts and deletes into a large database. One
of the many slowdowns was from MemSet. I found an old (2002) thread
about this and retried the tests (see below). The main point is that
the system memset crushes pg's!! Is it possible to add a define to call
the system memset at build time! This probably isn't the case on other
systems.
I wanted to know the size of FunctionCallInfoData (in execQual.c)
because the profiler said that if it was over 128 then use the system
call.
Here are my results:
pgMemSet
* 64
0.410u 0.000s 0:00.42 97.6% 0+0k 0+0io 0pf+0w
* 128
0.600u 0.000s 0:00.61 98.3% 0+0k 0+0io 0pf+0w
* 176 Size of fcinfo is 176, used in execQual.c which was being very
slow here!
0.790u 0.000s 0:00.79 100.0% 0+0k 0+0io 0pf+0w
* 256
1.040u 0.000s 0:01.08 96.2% 0+0k 0+0io 0pf+0w
* 512
2.030u 0.000s 0:02.04 99.5% 0+0k 0+0io 0pf+0w
* 1024
3.950u 0.010s 0:03.94 100.5% 0+0k 0+0io 0pf+0w
* 2048
7.710u 0.000s 0:07.75 99.4% 0+0k 0+0io 0pf+0w
* 4096
15.390u 0.000s 0:15.37 100.1% 0+0k 0+0io 0pf+0w
system memset
* 64
0.260u 0.000s 0:00.25 104.0% 0+0k 0+0io 0pf+0w
* 128
0.310u 0.000s 0:00.31 100.0% 0+0k 0+0io 0pf+0w
* 176 Size of fcinfo is 176
0.300u 0.010s 0:00.30 103.3% 0+0k 0+0io 0pf+0w
* 256
0.310u 0.000s 0:00.30 103.3% 0+0k 0+0io 0pf+0w
* 512
0.350u 0.000s 0:00.33 106.0% 0+0k 0+0io 0pf+0w
* 1024
0.590u 0.010s 0:00.63 95.2% 0+0k 0+0io 0pf+0w
* 2048
0.780u 0.000s 0:00.77 101.2% 0+0k 0+0io 0pf+0w
* 4096
1.320u 0.000s 0:01.33 99.2% 0+0k 0+0io 0pf+0w
#include <string.h> #include "postgres.h" #include "fmgr.h"
#undef MEMSET_LOOP_LIMIT #define MEMSET_LOOP_LIMIT 1000000
int main(int argc, char **argv) { int len = atoi(argv[1]); char buffer[len]; long long i;
FunctionCallInfoData fcinfo; printf("Size of fcinfo is %d\n", sizeof(fcinfo));
for (i = 0; i < 9900000; i++) MemSet(buffer, 0, len); //memset(buffer, 0, len); return 0; }