Skip to content

feat(windows): optimise network change detection - #9021

Merged
thomaseizinger merged 7 commits into
mainfrom
chore/windows-better-network-changes
May 6, 2025
Merged

feat(windows): optimise network change detection#9021
thomaseizinger merged 7 commits into
mainfrom
chore/windows-better-network-changes

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented May 5, 2025

Copy link
Copy Markdown
Member

Presently, the network change detection on Windows is very naive and simply emits a change event everytime anything changes. We can optimise this and therefore improve the start-up time of Firezone by:

  • Filtering out duplicate events
  • Filtering out network change events for our own network adapter

This reduces the number of network change events to 1 during startup. As far as I can tell from the code comments in this area, we explicitly send this one to ensure we don't run into a race condition whilst we are starting up.

Resolves: #8905

@thomaseizinger
thomaseizinger requested a review from jamilbk May 5, 2025 05:11
@vercel

vercel Bot commented May 5, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 5, 2025 6:53am

@thomaseizinger
thomaseizinger marked this pull request as ready for review May 5, 2025 05:14
Copilot AI review requested due to automatic review settings May 5, 2025 05:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes Windows network change detection by filtering duplicate events and ignoring events from the Firezone network adapter to reduce unnecessary startup activity.

  • Filters out duplicate network change events
  • Adds detection and exclusion for the Firezone network adapter
  • Introduces registry lookup to retrieve the Firezone adapter GUID
Comments suppressed due to low confidence (1)

rust/bin-shared/src/network_changes/windows.rs:411

  • [nitpick] Consider handling the poisoned mutex lock explicitly rather than unwrapping silently. This can reduce potential hidden issues if the lock is poisoned.
.lock().unwrap_or_else(|e| e.into_inner())

Comment thread rust/bin-shared/src/network_changes/windows.rs Outdated
@thomaseizinger

Copy link
Copy Markdown
Member Author

@jamilbk Would appreciate if you could give this a brief smoke test on your Windows machine. Disabling the primary network adapter is tricky in a VM because it is the one I am connected to via RDP so I can't really test that.

Comment thread rust/bin-shared/src/network_changes/windows.rs

@jamilbk jamilbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a couple questions but otherwise the logic LGTM.

Tested on Windows 11 by switching from WiFi -> Ethernet and back a few a times.

Comment thread rust/bin-shared/src/network_changes/windows.rs
Comment thread rust/bin-shared/src/network_changes/windows.rs
@thomaseizinger
thomaseizinger added this pull request to the merge queue May 6, 2025
Merged via the queue into main with commit 005b6fe May 6, 2025
@thomaseizinger
thomaseizinger deleted the chore/windows-better-network-changes branch May 6, 2025 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows client spams "Resetting network state"

3 participants