Slow the WG connectivity watchdog when the screen is off - #749
Open
kasnder wants to merge 1 commit into
Open
Conversation
The liveness monitor polled tunnel counters every second for as long as the tunnel ran, including overnight with the screen off — a CPU wake per second for hours, for a watchdog whose purpose is catching stalls while traffic flows. Poll at 15s instead while the screen is off (1s when interactive), and scale the doze-detection gap threshold with the active interval so the slow cadence is not mistaken for a suspension.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WgConnectivityMonitorpolls the tunnel's transfer counters every second for as long as the WireGuard tunnel runs — including overnight with the screen off. The monitor is fully passive (counter reads over JNI; it never wakes the radio and holds no wakelock), but each poll still costs a CPU wake, so a healthy idle tunnel burned one wakeup per second between screen-off and deep doze. Its purpose is catching stalls while traffic flows, which overwhelmingly happens with the screen on.Change
WgConnectivityMonitor.pollIntervalMs). The cadence is sampled each iteration from a newisInteractivesupplier, backed byWgEgress.currentInteractive(now@Volatile, since the monitor thread reads it).isSuspendGap): a gap past one full cycle + 5s margin means doze. This preserves the previous fixed 6s threshold at the 1s cadence and prevents the normal 15s background cycle from being mistaken for a suspension.onSuspendedrebasing are untouched. Background sync still gets stall detection within one 15s cycle.Testing
WgConnectivityMonitorTest: cadence mapping, threshold preserved at 6s on the interactive cadence, threshold scales past the idle cadence without false suspend detection.WgConnectivityCheckerTestandWgEgressRecoveryTestpass unmodified.