Skip to content

Commit 33c8276

Browse files
authored
Improve chrony reliability on Azure: add systemd override (FIFO scheduling, priority 50, OOMScoreAdjust -500) change Hyper-V PTP refclock poll 3 -> -1 (sampling interval max from 8s to 0.5s; with dpoll -2 dynamic range shifts from 2-8s to 0.125-0.5s) for tighter offset/jitter. (#442)
1 parent b64945e commit 33c8276

File tree

1 file changed

+17
-1
lines changed
  • stemcell_builder/stages/bosh_azure_chrony

1 file changed

+17
-1
lines changed

stemcell_builder/stages/bosh_azure_chrony/apply.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@ base_dir=$(readlink -nf $(dirname $0)/../..)
66
source $base_dir/lib/prelude_apply.bash
77
source $base_dir/lib/prelude_bosh.bash
88

9+
mkdir -p /etc/systemd/system/chrony.service.d
10+
11+
cat > $chroot/etc/systemd/system/chrony.service.d/chrony-systemd-override.conf <<EOF
12+
# created by $0
13+
[Service]
14+
# Set the CPU scheduling policy to FIFO (First-In, First-Out), a real-time policy.
15+
CPUSchedulingPolicy=fifo
16+
17+
# Set the real-time priority to the highest possible value (99).
18+
# This ensures chronyd runs before any other non-kernel, non-real-time tasks.
19+
CPUSchedulingPriority=50
20+
21+
# Make the process less likely to be killed by the OOM killer
22+
OOMScoreAdjust=-500
23+
EOF
24+
925
cat > $chroot/etc/chrony/conf.d/azure_ptp.conf <<EOF
1026
# created by $0
1127
# https://docs.microsoft.com/en-us/azure/virtual-machines/linux/time-sync#chrony
12-
refclock PHC /dev/ptp_hyperv poll 3 dpoll -2 offset 0 stratum 2
28+
refclock PHC /dev/ptp_hyperv poll -1 dpoll -2 offset 0 stratum 2
1329
EOF

0 commit comments

Comments
 (0)