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: 2017-01-04 04:00:32
Message-ID: CAJrrPGfDYekY7PMDcQdi2Zj7KpdLO_ZuAVNv16FMbp98EGEeJw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 30, 2016 at 1:02 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com> writes:
> > Attached a patch that replaces most of the getimeofday function calls,
> > except timeofday(user callable) and GetCurrentTimestamp functions.
>
> I looked at this for awhile and could not convince myself that it's
> a good idea. Trying to do s/gettimeofday/clock_gettime/g is not going
> to do much for us except create portability headaches. According
> to my tests, clock_gettime is not noticeably faster than gettimeofday
> on any platform, except that if you use nonstandard clockids like
> CLOCK_REALTIME_COARSE then on *some* platforms it's a little bit quicker,
> at the cost of being a great deal less precise. But we'd have to research
> the existence and effects of nonstandard clockids on every platform.
> So AFAICS the only clear advantage to switching is the extra precision
> available from clock_gettime.
>
> But ... most of the places you've touched in this patch have neither any
> need for sub-microsecond precision nor any great need to worry about
> shaving a few ns off the time taken by the call. As far as I can find,
> the only place where it's actually worth our trouble to deal with it is
> instr_time.h (ie, EXPLAIN ANALYZE and a few other uses).
>
> So I think we should do something more like the attached.
>

Thanks for your valuable input.

As the getimeofday() function is obsolete and any further enhancements
may happen to clock_gettime() function only, because of this reason, I
changed
it many places.

Yes, I agree that until unless the clock_gettime() function that performs
faster
in all platforms compared to gettimeofday(), we can retain the getimeofday()
function.

Regards,
Hari Babu
Fujitsu Australia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2017-01-04 04:08:55 Re: Logical decoding on standby
Previous Message Haribabu Kommi 2017-01-04 03:54:16 Re: pg_hba_file_settings view patch