This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 08/10] Use clock_gettime to implement gettimeofday.



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
>> 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.

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 [1], and 
change the fallback syscall path to call clock_gettime instead.  I can work
towards the modification.

[1] https://sourceware.org/ml/libc-alpha/2019-07/msg00158.html


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]