On Sat, 6 Jul 2019, Paul Smith wrote: > I looked at the code in libstdc++-v3 and as far as I can tell I'm using > CLOCK_MONOTONIC for my steady_clock; this is in libstdc++-v3/config.h: > > #define _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL 1 ^ this is a problem, your libstdc++ library is configured to use the syscall directly instead of letting the libc go via the VDSO fastpath. Most likely you're building GCC against old glibc where clock_gettime requires linking with -lrt; have a look at the documentation for --enable-libstdcxx-time= in the libstdc++ manual, https://gcc.gnu.org/onlinedocs/gcc-9.1.0/libstdc++/manual/manual/configure.html > Here's a gdb disassembly of the "fast" clock_gettime() version: > [..] > <+18>: callq 0x40c730 <clock_gettime@plt> this typically goes via VDSO without a context switch > And of the std::chrono::steady_clock::now() function: > [..] > <+19>: callq 0x40b950 <syscall@plt> this requires a context switch to the kernel and back. Alexander