Re: gettimeofday is at the end of its usefulness? - Mailing list pgsql-hackers

From Andres Freund
Subject Re: gettimeofday is at the end of its usefulness?
Date
Msg-id 20140515111439.GL23943@awork2.anarazel.de
Whole thread Raw
In response to Re: gettimeofday is at the end of its usefulness?  (Benedikt Grundmann <bgrundmann@janestreet.com>)
List pgsql-hackers
On 2014-05-15 12:04:25 +0100, Benedikt Grundmann wrote:
> On Thu, May 15, 2014 at 11:31 AM, Greg Stark <stark@mit.edu> wrote:
> 
> > On Thu, May 15, 2014 at 8:19 AM, Benedikt Grundmann
> > <bgrundmann@janestreet.com> wrote:
> > > I posted this on this mailing list before at Jane Street we have
> > developed
> > > very fast code to get timing information based on TSC if available.  It's
> > > all ocaml but well documented and mostly just calls to c functions so
> > should
> > > be easy to port to C and we release it under a very liberal license so it
> > > should be no problem to take the ideas:
> >
> > What OS do you run it on though? How fast is your implementation
> > compared to the kernel implementation of clock_gettime()?
> >
> > Are you sure your implementation is actually faster? And are you sure
> > you're protected against clocks going backwards? I think you should
> > put some i/o in the loop in the test and start several threads running
> > it to make it more likely the thread is rescheduled to a different
> > processor during the test. It suspect you'll find the rdtsc goes
> > backwards sometimes or produces crazy results when switching
> > processors.
> >
> >
> There are benchmarks in the link I posted (obtained by a micro benchmarking
> library we developed / use internally which takes great care to obtain
> reliable numbers) .  We use posix threads extensively. We internally spend
> a lot of time setting up ntp and monitoring systems so that clock backwards
> never happens (so with other words I wouldn't be surprised if the library
> does NOT work correctly when it does  -- our protection is outside).  I do
> not believe we have seen the tdtsc going backwards on thread context switch
> you mention (and as said we use lots of threads).  OS?  Centos 6.5
> primarily.

Did you test it on server with more one socket (i.e. not just multiple
cores, but distinct cpu cases)? That's where you expect to see
differences in TSC to have funny effects.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Benedikt Grundmann
Date:
Subject: Re: gettimeofday is at the end of its usefulness?
Next
From: Andres Freund
Date:
Subject: Re: gettimeofday is at the end of its usefulness?