Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always update network interfaces information in cache #3

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

bobrofon
Copy link
Contributor

@bobrofon bobrofon commented Aug 2, 2024

anet.Interfaces and net.Interfaces use the same zoneCache underneath (and the same lastFetched). But because net.Interfaces is currently not fully functional on Android, it always tries to clear the cache and update the lastFetched timestamp. In certain situations, this may prevent anet.Interfaces from populating the cache at all.

Example pseudocode:

  for {
    _, _ = net.Listen(...) // clears zoneCache, updates the timestamp
    _, _ = anet.Interfaces() // doesn't update the cache because it's up to date
  }

The zoneCache is used to reduce the cost of resolving IPv6 addressing scope zones. Because all expensive operations have already been performed in anet.Interfaces, there is no reason not to update the cache (even if it has recent timestamp).

`anet.Interfaces` and `net.Interfaces` use the same `zoneCache`
underneath (and the same `lastFetched`). But because `net.Interfaces`
is currently not fully functional on Android, it always tries to clear
the cache and update the `lastFetched` timestamp. In certain
situations, this may prevent `anet.Interfaces` from populating the
cache at all.

Example pseudocode:
  for {
    _, _ = net.Listen(...) // clears zoneCache, updates the timestamp
    _, _ = anet.Interfaces() // doesn't update the cache because it's up to date
  }

The `zoneCache` is used to reduce the cost of resolving IPv6
addressing scope zones. Because all expensive operations have already
been performed in `anet.Interfaces`, there is no reason not to update
the cache (even if it has recent timestamp).
@wlynxg wlynxg merged commit 4d6caa2 into wlynxg:main Aug 2, 2024
@bobrofon bobrofon deleted the zone-cache-starvation branch August 2, 2024 16:46
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.

2 participants