pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: instr_time: Represent time as an int64 on all platforms
Date: Mon, 23 Jan 2023 14:22:06 +0900
Message-ID: <Y84ZfhnTWJThOhUO@paquier.xyz> (raw)
In-Reply-To: <E1pJ6NT-004jOH-DF@gemulon.postgresql.org>
References: <E1pJ6NT-004jOH-DF@gemulon.postgresql.org>

Hi Andres,

On Sat, Jan 21, 2023 at 05:25:19AM +0000, Andres Freund wrote:
> instr_time: Represent time as an int64 on all platforms
> 
> Until now we used struct timespec for instr_time on all platforms but
> windows. Using struct timespec causes a fair bit of memory (struct timeval is
> 16 bytes) and runtime overhead (much more complicated additions). Instead we
> can convert the time to nanoseconds in INSTR_TIME_SET_CURRENT(), making the
> remaining operations cheaper.
> 
> Representing time as int64 nanoseconds provides sufficient range, ~292 years
> relative to a starting point (depending on clock source, relative to the unix
> epoch or the system's boot time). That'd not be sufficient for calendar time
> stored on disk, but is plenty for runtime interval time measurement.
> 
> On windows instr_time already is represented as cycles. It might make sense to
> represent time as cycles on other platforms as well, as using cycle
> acquisition instructions like rdtsc directly can reduce the overhead of time
> acquisition substantially. This could be done in a fairly localized manner as
> the code stands after this commit.
> 
> Because the windows and non-windows paths are now more similar, use a common
> set of macros. To make that possible, most of the use of LARGE_INTEGER had to
> be removed, which looks nicer anyway.
> 
> To avoid users of the API relying on the integer representation, we wrap the
> 64bit integer inside struct struct instr_time.
> 
> Author: Andres Freund <andres@anarazel.de>
> Author: Lukas Fittl <lukas@fittl.com>

hoverfly is unhappy since this went in:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=hoverfly&dt=2023-01-23%2005%3A01%3A44

"../../../src/include/portability/instr_time.h", line 116.9: 1506-304 (I) No function prototype given for "clock_gettime".
"../../../src/include/portability/instr_time.h", line 116.23: 1506-045 (S) Undeclared identifier CLOCK_REALTIME.
<builtin>: recipe for target 'plpy_cursorobject.o' failed

Thanks,
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (7+ messages)  latest in thread

Message-ID: <Y84ZfhnTWJThOhUO@paquier.xyz>
Permalink:  ../Y84ZfhnTWJThOhUO@paquier.xyz/
Also on:    postgresql.org/message-id/Y84ZfhnTWJThOhUO@paquier.xyz

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, andres@anarazel.de
  Subject: Re: pgsql: instr_time: Represent time as an int64 on all platforms
  In-Reply-To: <Y84ZfhnTWJThOhUO@paquier.xyz>
  References: <E1pJ6NT-004jOH-DF@gemulon.postgresql.org> <Y84ZfhnTWJThOhUO@paquier.xyz>

* 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