…tonic clock)
There is no bug in Linux, the issue that CLOCK_MONOTONIC returns values
less then previous calls likely happens due to adjtime(3) (NTP), since
CLOCK_MONOTONIC is affected by it, and I've seen lots of slight time
modifications due to NTP on the servers. And even on my desktop (I also
have NTP enabled):
CLOCK_MONOTONIC: 189292.803 (2 days + 4h 34m 52s)
CLOCK_MONOTONIC_RAW: 189290.016 (2 days + 4h 34m 50s)
However on Linux there is CLOCK_MONOTONIC_RAW, it is similar to
CLOCK_MONOTONIC, but does not affected by the adjtime(3).
About performance, it is the same:
CLOCK_MONOTONIC 10e6: real=0m0.191s user=0m0.190s sys=0m0.000s
CLOCK_MONOTONIC_RAW 10e6: real=0m0.191s user=0m0.191s sys=0m0.000s
Ops/s:
- AMD Threadripper: 52.3e6
- Xeon Silver 4216 2.10: 46.5e6
Fixes: c5d631c
Fixes: ClickHouse#29811 (cc @tavplubix)
Signed-off-by: Azat Khuzhin <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Use CLOCK_MONOTONIC_RAW over CLOCK_MONOTONIC on Linux (fixes non monotonic clock)
There is no bug in Linux, the issue that CLOCK_MONOTONIC returns values less then previous calls likely happens due to adjtime(3) (NTP), since CLOCK_MONOTONIC is affected by it, and I've seen lots of slight time modifications due to NTP on the servers. And even on my desktop (I also have NTP enabled):
However on Linux there is CLOCK_MONOTONIC_RAW, it is similar to CLOCK_MONOTONIC, but does not affected by the adjtime(3).
About performance, it is the same:
Ops/s:
Fixes: c5d631c
Fixes: #29811 (cc @tavplubix)
Fixes: #29154