-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update the way NTP sync uses
adjtimex
syscall
Fixes #3582 Time adjustment code was rewritten taking a peek at other time sync implementations. Looks like `adjtimex` was used incorrectly before which leads to huge time oscillations and `STA_UNSYNC` being set by the kernel. Instead of setting time via `settimeofday`, use `adjtimex` as well to set the time on big jump. With this change, oscillation is pretty stable around zero, in microsecond range (polling interval lowered for testing): ``` 172.20.0.2: 2021/05/06 18:51:28 time.SyncController: adjusting time (slew) by -11.375µs via 192.36.143.130, state TIME_OK, status STA_PLL | STA_NANO 172.20.0.2: 2021/05/06 18:51:37 time.SyncController: adjusting time (slew) by 426.276µs via 192.36.143.130, state TIME_OK, status STA_PLL | STA_NANO 172.20.0.2: 2021/05/06 18:51:50 time.SyncController: adjusting time (slew) by -622.037µs via 192.36.143.130, state TIME_OK, status STA_PLL | STA_NANO 172.20.0.2: 2021/05/06 18:51:58 time.SyncController: adjusting time (slew) by 59.822µs via 192.36.143.130, state TIME_OK, status STA_PLL | STA_NANO 172.20.0.2: 2021/05/06 18:52:11 time.SyncController: adjusting time (slew) by 126.855µs via 192.36.143.130, state TIME_OK, status STA_NANO | STA_PLL 172.20.0.2: 2021/05/06 18:52:20 time.SyncController: adjusting time (slew) by 17.334µs via 192.36.143.130, state TIME_OK, status STA_NANO | STA_PLL 172.20.0.2: 2021/05/06 18:52:28 time.SyncController: adjusting time (slew) by -108.787µs via 192.36.143.130, state TIME_OK, status STA_NANO | STA_PLL 172.20.0.2: 2021/05/06 18:52:34 time.SyncController: adjusting time (slew) by -71.687µs via 192.36.143.130, state TIME_OK, status STA_PLL | STA_NANO 172.20.0.2: 2021/05/06 18:52:40 time.SyncController: adjusting time (slew) by 114.759µs via 192.36.143.130, state TIME_OK, status STA_PLL | STA_NANO 172.20.0.2: 2021/05/06 18:52:47 time.SyncController: adjusting time (slew) by 46.716µs via 192.36.143.130, state TIME_OK, status STA_PLL | STA_NANO ``` Also one should pick a time server close to the node to get lower RTT and dispersion. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
- Loading branch information
Showing
2 changed files
with
80 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters