Re: gettimeofday is at the end of its usefulness?

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: gettimeofday is at the end of its usefulness?
Date: 2016-12-29 21:05:39
Message-ID: CAEepm=11a1_eYHt4ET_LpgUsuCkzX=dqmCXBkY8ed1=uhZe8mA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 27, 2016 at 10:34 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I also tried FreeBSD 11.0 on another Mac (2.3GHz x86_64),
> and found that gettimeofday as well as basically all their
> clock_gettime variants run in 27 to 28 ns; and clock_gettime
> reliably delivers full precision, except for CLOCK_SECOND which
> is intentionally truncated to 1s precision. So there would be
> no need to work with anything but CLOCK_MONOTONIC here.
>
> However, it seems that these impressive results date back only to
> June 2012, cf
> https://github.com/freebsd/freebsd/commit/13a9f42818f6b89a72b3e40923be809b490400d8
> and at least as of that commit, only x86 and x86_64 had the fast
> clock_gettime code. Older FreeBSD, or FreeBSD on another architecture,
> is likely to be a lot worse. But I lack an installation to try.

That commit is in every 'production' and 'legacy' release of
FreeBSD[1], meaning as far back as 9.3 (expected to be EoL in the next
few days), because it landed in 9.2 (EoL). ARM support landed in
FreeBSD 11.0[2]. That leaves the following architectures without
fast-path time functions:

macaque:freebsd munro$ git grep 'trivial-vdso_tc.c'
lib/libc/mips/sys/Makefile.inc:SRCS+= trivial-vdso_tc.c
lib/libc/powerpc/Makefile.inc:SRCS+= trivial-vdso_tc.c
lib/libc/powerpc64/Makefile.inc:SRCS+= trivial-vdso_tc.c
lib/libc/powerpcspe/Makefile.inc:SRCS+= trivial-vdso_tc.c
lib/libc/riscv/sys/Makefile.inc:SRCS+= trivial-vdso_tc.c
lib/libc/sparc64/Makefile.inc:SRCS+= trivial-vdso_tc.c

[1] https://www.freebsd.org/releases/
[2] https://github.com/freebsd/freebsd/commit/80e8626b434515d16b3576174438526755336810

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-12-29 21:18:42 Re: gettimeofday is at the end of its usefulness?
Previous Message Tom Lane 2016-12-29 21:02:31 Re: gettimeofday is at the end of its usefulness?