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.


* 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


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