pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Haribabu Kommi <kommi.haribabu@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: gettimeofday is at the end of its usefulness?
Date: Thu, 29 Dec 2016 21:02:49 +0100
Message-ID: <87y3yyfqqe.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <15740.1482788055@sss.pgh.pa.us>
References: <31856.1400021891@sss.pgh.pa.us>
	<20140515185614.GG25053@momjian.us>
	<CAA-aLv7m=RU0vKm1myt_uRLYmTviqFcfWZCMPwbXdbKoX4YzYg@mail.gmail.com>
	<20237.1465397783@sss.pgh.pa.us>
	<CAJrrPGd2rA6UoPOxUK1WRgKfxRYB7vQZ357zCv+6kx3ced7v4g@mail.gmail.com>
	<CAJrrPGecetyS5m1F8v4jOUFqy0zGr7hR8kgDMiq1HWeOKB3_oA@mail.gmail.com>
	<15740.1482788055@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

* Tom Lane:

> On Linux (RHEL6, 2.4GHz x86_64), I find that gettimeofday(),
> clock_gettime(CLOCK_MONOTONIC), and clock_gettime(CLOCK_REALTIME)
> all take about 40ns.  Of course gettimeofday() only has 1us resolution,
> but the other two have perhaps 10ns resolution (I get no duplicate
> readings in a tight loop).  Other documented clockids include
>     CLOCK_REALTIME_COARSE: about 10ns to read, but only 1ms resolution
>     CLOCK_MONOTONIC_COARSE: about 12ns to read, but only 1ms resolution
>     CLOCK_MONOTONIC_RAW: full resolution but very slow, ~145ns to read
> So CLOCK_MONOTONIC seems to be the thing to use here.  It won't buy
> us anything speed-wise but the extra resolution will be nice.
> However, we need to do more research to see if this holds true on
> other popular distros.

Isn't this very specific to kernel and glibc versions, depending on
things like CONFIG_HZ settings and what level of vDSO support has been
backported?


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (34+ messages)  latest in thread

Message-ID: <87y3yyfqqe.fsf@mid.deneb.enyo.de>
Permalink:  ../87y3yyfqqe.fsf@mid.deneb.enyo.de/
Also on:    postgresql.org/message-id/87y3yyfqqe.fsf@mid.deneb.enyo.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: fw@deneb.enyo.de, tgl@sss.pgh.pa.us, kommi.haribabu@gmail.com
  Subject: Re: gettimeofday is at the end of its usefulness?
  In-Reply-To: <87y3yyfqqe.fsf@mid.deneb.enyo.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox