Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wktiy-0000mx-Ef for pgsql-hackers@arkaria.postgresql.org; Thu, 15 May 2014 11:21:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wktix-0001kL-OM for pgsql-hackers@arkaria.postgresql.org; Thu, 15 May 2014 11:21:19 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wktiw-0001kA-8Z for pgsql-hackers@postgreSQL.org; Thu, 15 May 2014 11:21:18 +0000 Received: from mout.kundenserver.de ([212.227.17.10]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wktip-0005wK-96 for pgsql-hackers@postgreSQL.org; Thu, 15 May 2014 11:21:17 +0000 Received: from anarazel.de (p5DDC6C0A.dip0.t-ipconnect.de [93.220.108.10]) by mrelayeu.kundenserver.de (node=mreue101) with ESMTP (Nemesis) id 0MgOVK-1WORBy3Vzi-00Nldy; Thu, 15 May 2014 13:21:08 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 327671022B9; Thu, 15 May 2014 13:21:08 +0200 (CEST) Date: Thu, 15 May 2014 13:21:08 +0200 From: Andres Freund To: Tom Lane Cc: pgsql-hackers@postgreSQL.org Subject: Re: gettimeofday is at the end of its usefulness? Message-ID: <20140515112108.GM23943@awork2.anarazel.de> References: <31856.1400021891@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <31856.1400021891@sss.pgh.pa.us> X-Provags-ID: V02:K0:t8ILJilpqEn2VZjUJjzAmmwDCrB8JzzAplXFUhMfdpj j4CGO7bZjC44w/WI8feu7akF+Awxj0/fYdKnO7J5ElMBoi/Jc3 fVnFJWsAGS0bmgJCQihWtbvmX6y80WWSiiirjRoTpe6pe8db9L qoGrutNrnZWGoZjsTdIvzNbb54ySs+9DhPrvHv1u5l+lx1rA+z xKWdjaI2HuCow5VM+5aUziZpZWngGzWb2Jvw5E2kInSx/swjM3 tGsvfcfKJwEMZqv91G9QLsYgyC7QblfO9wh5uAdhDmQ47nfpeM Jr/EhoSVIi9aQIScm53F0ullRQQqKocXMSwIkf8Oj3Rd4ZYf0M r/G/D4AyzXH4ebdnWdtuZV16MvQZILRZcwjz/e1VD X-Pg-Spam-Score: -1.9 (-) 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 Hi, On 2014-05-13 18:58:11 -0400, Tom Lane wrote: > Anyway it looks like clock_gettime() might be worth using on Linux > just for the more precise output. It doesn't seem to exist on OS X > though, and I have no idea about elsewhere. Agreed that using clock_gettime() would be a good idea. I'd say we should have a wrapper around it that is able to provide nanosecond precision. If only gettimeofday() (and whatever windows is using) is available, we can dynamically fall back to that. > I'm curious if anybody has ideas about other things we might do for > portable high-precision timing. It's far from a solve-it-all, but can we perhaps try to coalesce repeated time measurements? We'll very frequently do a InstrStopNode(); /* minimal amount of work */ InstrStartNode(); which will measure the time twice. I think there's a fair number of scenarios where once would be enough. I'll freely admit that I haven't looked enough to determine how we could do that API wise. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers