Re: gettimeofday is at the end of its usefulness?

From: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: gettimeofday is at the end of its usefulness?
Date: 2016-09-14 00:53:08
Message-ID: CAJrrPGecetyS5m1F8v4jOUFqy0zGr7hR8kgDMiq1HWeOKB3_oA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 25, 2016 at 3:12 PM, Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
wrote:

> On Thu, Jun 9, 2016 at 12:56 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Thom Brown <thom(at)linux(dot)com> writes:
> >> On 15 May 2014 at 19:56, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> >>> On Tue, May 13, 2014 at 06:58:11PM -0400, Tom Lane wrote:
> >>>> A recent question from Tim Kane prompted me to measure the overhead
> >>>> costs of EXPLAIN ANALYZE, which I'd not checked in awhile. Things
> >>>> are far worse than I thought. On my current server (by no means
> >>>> lavish hardware: Xeon E5-2609 @2.40GHz) a simple seqscan can run
> >>>> at something like 110 nsec per row:
> >
> >> Did this idea die, or is it still worth considering?
> >
> > We still have a problem, for sure. I'm not sure that there was any
> > consensus on what to do about it. Using clock_gettime(CLOCK_REALTIME)
> > if available would be a straightforward change that should ameliorate
> > gettimeofday()'s 1-usec-precision-limit problem; but it doesn't do
> > anything to fix the excessive-overhead problem. The ideas about the
> > latter were all over the map, and none of them looked easy.
> >
> > If you're feeling motivated to work on this area, feel free.
>
> How about using both CLOCK_REALTIME and CLOCK_REALTIME_COARSE
> as the clock id's in clock_gettime wherever applicable. COARSE option is
> used
> wherever there is no timing calculation is required, because in my laptop,
> there
> is a significant performance difference is observed (like 8 times)
> compared to
> CLOCK_REALTIME.
>
> If it is fine, I will try to update the code and send a patch.
>

Attached a patch that replaces most of the getimeofday function calls,
except
timeofday(user callable) and GetCurrentTimestamp functions.

Didn't add any configure checks in case if the clock_gettime function is
not available,
the fallback logic to gettimeofday function call.

Any comments in proceeding further?

Regards,
Hari Babu
Fujitsu Australia

Attachment Content-Type Size
clock_gettime_1.patch application/octet-stream 33.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-09-14 01:04:38 Re: WAL consistency check facility
Previous Message Tatsuo Ishii 2016-09-14 00:50:12 Re: Event trigger and CREATE/ALTER ROLE/USER