From e35955da827ae6df39dd83fec21069c0c42db2cd Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Wed, 15 Jul 2026 14:18:55 +0200 Subject: [PATCH] etc/systemd/system/wait-network-online.service: Reduce loop timeout from 1 s to 0.1 s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So the 7s splits into two very different halves: ┌─────────────────────────────────────────────┬──────────┬────────────────────────────────────────────────────────────────────────┐ │ Segment │ Duration │ Cause │ ├─────────────────────────────────────────────┼──────────┼────────────────────────────────────────────────────────────────────────┤ │ service start → carrier up (2.962 → 6.694) │ ~3.73s │ r8169 gigabit link negotiation. Ping cannot succeed here — no carrier. │ ├─────────────────────────────────────────────┼──────────┼────────────────────────────────────────────────────────────────────────┤ │ carrier up → ping succeeds (6.694 → 10.028) │ ~3.33s │ your loop's granularity + DNS/ARP on the first real attempt │ └─────────────────────────────────────────────┴──────────┴────────────────────────────────────────────────────────────────────────┘ The second half is the surprising one, and it's entirely self-inflicted by the loop shape: while ! ping -c 1 -w 1 rick.molgen.mpg.de; do sleep 1 ; done Two costs stack up after the link is already up at 6.694s: 1. Coarse polling. Each miss is ping -w 1 (up to 1s) plus sleep 1 — up to ~2s of dead time per iteration. When carrier came up at 6.694s the loop was almost certainly mid-sleep 1, so you eat the rest of a sleep, then a failed attempt, then another sleep before the winning ping. That alone explains ~2–3s. 2. DNS every iteration. You ping a hostname, so each attempt resolves rick.molgen.mpg.de first. Early in boot the resolver can stall/retry, and it's on the hot path for every loop pass. So ~3.7s is a hardware/switch floor (gigabit autoneg — Link Down 3.98s → Up 6.69s), but ~3s is recoverable in software. Concrete fix Tighten the loop and take DNS out of the path: ExecStart=/bin/bash -c 'until ping -c1 -W1 >/dev/null 2>&1; do sleep 0.2; done' TimeoutStartSec=30 - Drop the sleep 1 → sleep 0.2: post-carrier dead time falls from up to ~2s to ~0.2s. - -W1 is the per-packet wait (fast fail while carrier is down returns immediately as "Network unreachable"), and the small sleep keeps it from busy-spinning during those ~3.7s. - Ping the IP (or put rick in /etc/hosts) to remove DNS retry variance. - TimeoutStartSec=30 so a genuinely-broken network fails the boot instead of hanging forever — your current infinite while has no guard. Expected effect: cuts the second half from ~3.3s to well under 1s, i.e. +7.066s → roughly ~4s (the carrier floor plus one clean ping). --- etc/systemd/system/wait-network-online.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/systemd/system/wait-network-online.service b/etc/systemd/system/wait-network-online.service index 425e7a29..8693b0af 100644 --- a/etc/systemd/system/wait-network-online.service +++ b/etc/systemd/system/wait-network-online.service @@ -8,7 +8,7 @@ Type=oneshot RemainAfterExit=true TimeoutStartSec=15 StandardOutput=null -ExecStart=bash -c 'while ! ping -c 1 -w 1 rick.molgen.mpg.de; do sleep 1 ; done' +ExecStart=bash -c 'while ! ping -c 1 -w 1 rick.molgen.mpg.de; do sleep 0.1 ; done' [Install] WantedBy=network-online.target