Στις Wednesday 12 January 2011 19:17:28 ο/η Mark Felder έγραψε: > On Wed, 12 Jan 2011 10:45:20 -0600, Tom Lane <tgl@xxxxxxxxxxxxx> wrote: > > > > The short of it is that cheap motherboards tend to provide cheap clock > > hardware that takes about a microsecond to read. > > I'm not sure how gettimeofday() works, but is there a slight chance this > could be alleviated by choosing a different kern.timecounter.hardware > option? > > kern.timecounter.choice: TSC(800) HPET(900) ACPI-fast(1000) i8254(0) > dummy(-1000000) > kern.timecounter.hardware: ACPI-fast > > Or does the kernel timer stuff have nothing to do with gettimeofday()? Thanx, Actually setting sysctl kern.timecounter.hardware=TSC and making the program look like: (increased the loop from 1,000,000 to 100,000,000) #include <stdio.h> #include <stdlib.h> #include <sys/time.h> int main(int argc,char** argv) { struct timeval *tp=calloc(1,sizeof(struct timeval)); int runna; double micros_total=0; for (runna=0;runna<100000000;runna++) { int rc=gettimeofday(tp,NULL); long micros = tp->tv_sec * 1000000 + tp->tv_usec; micros_total = micros_total + (double) micros; } printf("micros_total=%f\n",micros_total); } I get in LINUX_PROD time ./gettimeofday_test micros_total=129491418242412709937152.000000 real 0m16.665s user 0m16.621s sys 0m0.000s and in FBSD_TEST time ./gettimeofday_test micros_total=129491437864563859521536.000000 real 0m15.506s user 0m0.517s sys 0m1.161s So, the FBSD_TEST case although still involves some kernel overhead, it is faster than LINUX_PROD (but i am puzzled as to where those 15.5 secs come from since 1.16+ > > > Regards, > > > Mark > -- Achilleas Mantzios -- Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin