This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH v2 08/10] Use clock_gettime to implement gettimeofday.
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Florian Weimer <fweimer at redhat dot com>, Zack Weinberg <zackw at panix dot com>
- Cc: libc-alpha at sourceware dot org, Joseph Myers <joseph at codesourcery dot com>, Lukasz Majewski <lukma at denx dot de>, Alistair Francis <alistair23 at gmail dot com>, Stepan Golosunov <stepan at golosunov dot pp dot ru>, Arnd Bergmann <arnd at arndb dot de>, Samuel Thibault <samuel dot thibault at ens-lyon dot org>
- Date: Mon, 2 Sep 2019 16:31:25 -0300
- Subject: Re: [PATCH v2 08/10] Use clock_gettime to implement gettimeofday.
- References: <email@example.com> <firstname.lastname@example.org> <email@example.com>
On 28/08/2019 15:27, Florian Weimer wrote:
> * Zack Weinberg:
>> Remove sysdeps/unix/clock_gettime.c, which implemented clock_gettime
>> using gettimeofday; new OS ports must provide a real implementation of
> This comes at a performance cost. On a Xeon Gold 6126 with Fedora 31's
> 5.3.0-0.rc5.git0.1.fc31 kernel, I see 17.6 ns per gettimeofday call
> before this change, and 19.6 ns afterwards.
> Part of that is the additional overhead of the functional call and the
> clock check. I think gettimeofday should call directly into the vDSO.
> Another part according to profiles is the downscaling of the nanoseconds
> value. TIMESPEC_TO_TIMEVAL does not tell GCC that tv_nsec member does
> not use the full long range, so GCC emits a full 64-bit division (with a
> multiplication and shift).
> Both changes will hopefully recover the performance loss.
As for time patch from this set, I think we can still make the *default*
gettimeofday implementation use the clock_gettime if the architecture
does not have a faster way to accomplish it (through vDSO or the ifunc
trick to reduce latency). It would allow each arch-mantainer to set if
or when the architecture will move generic implementation and cleanup
the optimized glue.
My view is we can use my proposed patch to refactor gettimeofdat , and
change the fallback syscall path to call clock_gettime instead. I can work
towards the modification.