Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WkMsA-0005UZ-Kc for pgsql-hackers@arkaria.postgresql.org; Wed, 14 May 2014 00:16:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WkMs9-0008E3-Dg for pgsql-hackers@arkaria.postgresql.org; Wed, 14 May 2014 00:16:37 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WkMs7-0008Du-Vg for pgsql-hackers@postgresql.org; Wed, 14 May 2014 00:16:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WkMs5-0001lC-HE for pgsql-hackers@postgresql.org; Wed, 14 May 2014 00:16:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s4E0GTdp000837; Tue, 13 May 2014 20:16:29 -0400 From: Tom Lane To: Peter Geoghegan cc: Pg Hackers Subject: Re: gettimeofday is at the end of its usefulness? In-reply-to: References: <31856.1400021891@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Tue, 13 May 2014 16:33:32 -0700" Date: Tue, 13 May 2014 20:16:29 -0400 Message-ID: <836.1400026589@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) 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 Peter Geoghegan writes: > On Tue, May 13, 2014 at 3:58 PM, Tom Lane wrote: >> There's also a CLOCK_REALTIME_COARSE selector, which is noticeably faster >> --- about 10nsec for me --- but the output appears to only advance once >> every millisecond, so it's probably useless for our purposes. The other >> selectors mentioned in the Linux man page are considerably slower than >> CLOCK_REALTIME for me, suggesting that they actually call into the kernel. > What Linux kernel version is in use here? Ah, sorry, I should have specified. This is RHEL6.5, current kernel version 2.6.32-431.17.1.el6.x86_64. > Apparently, as I think > you've stated another way, more recent versions have VDSO for this, > which can make a big difference. This article seems like a sensible > guide to all of this: > https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_MRG/1.3/html/Realtime_Tuning_Guide/sect-Realtime_Tuning_Guide-General_System_Tuning-gettimeofday_speedup.html This appears to be talking about RHEL5, which is quite a bit older (and, I'd guess, trailing edge for anybody who might deploy PG 9.5). I did confirm that /proc/sys/kernel/vsyscall64 exists and has a default setting of 1 on RHEL6. Setting it to 0 causes gettimeofday to take 150ns, which probably represents the time for a trivial kernel call. The MRG extension described on the linked page doesn't seem to be implemented in stock RHEL6 (setting vsyscall64 to 2 is allowed but doesn't change behavior compared to 1). However, if I'm reading it right, all that does is make gettimeofday behave like clock_gettime(CLOCK_REALTIME_COARSE). > CLOCK_REALTIME_COARSE seemingly influences precision in a way that > allows user space applications to decide on their precision/cost > trade-off, rather than being forced to use the system default (that > procfs surfaces) through gettimeofday(): > http://lwn.net/Articles/342018/ Yeah, I think these are the same implementations exposed to apps in two different ways, one being a system-wide switch affecting gettimeofday() while the other allows the app source code to say which one it wants. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers