This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 08/10] Use clock_gettime to implement gettimeofday.
- From: Florian Weimer <fweimer at redhat dot com>
- To: 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>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Samuel Thibault <samuel dot thibault at ens-lyon dot org>
- Date: Wed, 28 Aug 2019 20:27:57 +0200
- Subject: Re: [PATCH v2 08/10] Use clock_gettime to implement gettimeofday.
- References: <20190828153236.18229-1-zackw@panix.com> <20190828153236.18229-9-zackw@panix.com>
* Zack Weinberg:
> Remove sysdeps/unix/clock_gettime.c, which implemented clock_gettime
> using gettimeofday; new OS ports must provide a real implementation of
> clock_gettime.
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.
Thanks,
Florian