I'm using CentOS Linux release 7.3.1611 on Intel(R) Xeon(R) CPU E5-2667 v4 @ 3.20GHz
During tests of my userspace application, I have noticed that clock_gettime(CLOCK_MONOTONIC, &ts) may take up to 5-6 microseconds instead of ~23 nanoseconds in average. It may happen only once per 10000 consequent calls, however it may happen.
If there were no VDSO library, it could be explained. However, VDSO is used for every clock_gettime (I checked it by strace).
No matter if corresponding thread is affined to certain CPU core, or not. No matter, if this CPU core isolated from OS, or not. It means test app may run on exclusive CPU core, while lag may appear anyway!
I'm measuring latency by comparing results of two consequent clock_gettime calls, like:
unsigned long long __gettimeLatencyNs() {
struct timespec t1_ts;
struct timespec t2_ts;
clock_gettime(CLOCK_MONOTONIC, &t1_ts);
clock_gettime(CLOCK_MONOTONIC, &t2_ts);
return ((t2_ts.tv_sec - t1_ts.tv_sec)*NANO_SECONDS_IN_SEC + t2_ts.tv_nsec - t1_ts.tv_nsec);
}
Could anyone share some ideas, what could be wrong there?