Skip to content

v5.0.9-06ab4d1

Choose a tag to compare

@github-actions github-actions released this 25 Apr 16:48
· 48 commits to main since this release
Immutable release. Only release title and notes can be modified.
06ab4d1

CPU & battery: stop streaming metrics when nobody's looking

This release cuts background CPU and battery usage by making the pipeline-metrics XPC stream opt-in. Before v5.0.9, opfilter sampled and pushed a PipelineMetricsSnapshot to every connected GUI client every second, regardless of whether anyone was looking at the Metrics screen — quietly burning cycles around the clock and producing a noticeable spike after resume from sleep.

Now opfilter samples and broadcasts only while the Metrics screen is visible. When the window is hidden or any other screen is active, the 1Hz sampling timer is suspended entirely — no sampling, no XPC fan-out, no pipeline_metrics os_log lines. Closing the window tears the subscription down immediately rather than waiting for SwiftUI lifecycle. Auto-resumes on reconnect when the Metrics screen is still active (mirrors v5.0.8 allow-stream resume).

Continues the work started in v5.0.8 (issue #144), which made the allow-event stream opt-in. Together they eliminate the steady-state background XPC traffic that previously kept opfilter busy.

Architecture

Dedicated MetricsBroadcaster (in opfilter/XPC/) owns the metrics subscription set and drives a MetricsTimerControlling collaborator on subscriber-count transitions (0 → 1 starts; 1 → 0 stops). DispatchSourceMetricsTimer is the production adapter, with idempotent start()/stop(). Mirrors the v5.0.8 allow-stream pattern.

Internal

  • New protocol MetricsTimerControlling and adapter DispatchSourceMetricsTimer.
  • XPCServer holds both EventBroadcaster and MetricsBroadcaster.
  • New ServiceProtocol methods: beginMetricsEventStream / endMetricsEventStream.
  • New XPCClient reconnect-resume seam: shouldResumeMetricsStream.
  • 7 new Swift Testing cases under @Suite("MetricsBroadcaster") covering subscriber transitions, timer start/stop, idempotency.

Commits

  • 06ab4d1 end metrics event stream when window hides
  • 763cd21 MetricsView subscribes to metrics stream while visible
  • ec21b16 wire metrics stream resume on reconnect
  • d182134 NavigationState exposes isMetricsScreenActive
  • dacc7ee XPCClient gains beginMetricsEventStream with reconnect resume
  • 4e43aac route metrics push through MetricsBroadcaster, gate timer on subscribers
  • 0cd4871 add DispatchSourceMetricsTimer adapter for 1Hz metrics
  • 0d61335 MetricsBroadcaster.broadcast no-ops without subscribers
  • a24bab2 cover idempotent metrics endStream
  • 84c65d8 MetricsBroadcaster.removeClient drops subscription and stops timer
  • 682cf36 MetricsBroadcaster.endStream stops timer on final unsubscribe
  • d326832 cover repeat-subscribe leaves metrics timer running once
  • 456f97d MetricsBroadcaster.beginStream starts timer on first subscriber
  • 7f6ba7f add MetricsBroadcaster scaffold with timer controller
  • b9d585c add MetricsTimerControlling protocol seam