Greg Smith <greg@2ndquadrant.com> writes:
> Tom Lane wrote:
>> You've got a machine where gettimeofday() is really slow. This is
>> common on cheap PC hardware :-(
> I'd be curious to know more about the hardware and operating system
> Szymon is using if you suspect this is the case. I keep hearing about
> systems where this is slow, but despite claims that they're common I've
> never actually seen one.
Well, they're not as common as they used to be. My understanding is
that there are two independent issues:
* If you have to call into the kernel to read the RTC, you're already
hurting. Modern Unixen avoid this, but I think I've read that it's
generally only fixed on x86_64 hardware not i386.
* The original specs for reading the RTC on PC hardware did not foresee
the desire of being able to read it out in a small fraction of a
microsecond. I don't know the details on this exactly, but some
googling turned up this:
http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-07/msg07415.html
The OP's example involved almost 21 seconds added by approximately
2*10000000 gettimeofday probes, or right about 1 microsecond per
probe...
regards, tom lane