Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cMgw4-0006GB-Sa for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Dec 2016 20:04:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cMgw3-0002c1-W6 for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Dec 2016 20:04:24 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cMguf-000129-Iz for pgsql-hackers@postgresql.org; Thu, 29 Dec 2016 20:02:57 +0000 Received: from albireo.enyo.de ([5.158.152.32]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cMguc-0002vN-Sp for pgsql-hackers@postgresql.org; Thu, 29 Dec 2016 20:02:56 +0000 Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1cMguX-0005Z7-Bx; Thu, 29 Dec 2016 21:02:49 +0100 Received: from fw by deneb.enyo.de with local (Exim 4.84_2) (envelope-from ) id 1cMguX-0004An-6H; Thu, 29 Dec 2016 21:02:49 +0100 From: Florian Weimer To: Tom Lane Cc: Haribabu Kommi , PostgreSQL-development Subject: Re: gettimeofday is at the end of its usefulness? References: <31856.1400021891@sss.pgh.pa.us> <20140515185614.GG25053@momjian.us> <20237.1465397783@sss.pgh.pa.us> <15740.1482788055@sss.pgh.pa.us> Date: Thu, 29 Dec 2016 21:02:49 +0100 In-Reply-To: <15740.1482788055@sss.pgh.pa.us> (Tom Lane's message of "Mon, 26 Dec 2016 16:34:15 -0500") Message-ID: <87y3yyfqqe.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org * 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