Repository navigation
Avoid getfqdn to speed things up on MacOS - #106
Merged
Merged
Conversation
pllim
reviewed
Oct 22, 2026
Member
|
Would also speed up CI if you reduce the number of jobs by addressing #103 😉 |
Member
Author
|
@pllim - think this is ready! |
pllim
reviewed
Oct 22, 2026
check_internet_off called socket.gethostname() and socket.getfqdn() on every intercepted bind/connect/create_connection. getfqdn() does a reverse DNS lookup of the local hostname, which takes ~35 s per call on GitHub's macOS runners, making the test suite take up to 15 minutes per tox command there (vs ~30 s on Linux). Connections to the machine's own hostname are still redirected to localhost, using only the cheap gethostname() call. Connections to any other name that resolves to a local interface (e.g. the FQDN) are now detected by attempting to bind to the resolved address, which only succeeds for local interfaces and requires no reverse DNS lookup.
The IPs of the allowed GitHub/Astropy data hosts were resolved on every intercepted socket call, so e.g. --remote-data=astropy did over 100 DNS lookups per test run. Cache _resolve_host_ips so each host is resolved once per process.
The hostname parameter only works when the blocker redirects the machine's own name to localhost; with --remote-data=any the blocker is off and the connection went to the LAN address, where the test server bound to localhost is not listening.
HTTPServer.server_bind calls socket.getfqdn() on the bound address, which takes ~35 s for the first call on GitHub's macOS runners and made test_localconnect_succeeds[localhost] the slowest test in the suite.
astrofrog
force-pushed
the
avoid-getfqdn
branch
from
October 22, 2026 22:01
d222a92 to
96b8d29
Compare
Member
Author
pllim
reviewed
Oct 22, 2026
Member
Author
|
@pllim How's this? |
Member
|
I gotta run. Feel free to merge! |
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.
The short version is,
getfqdnis really slow on Mac (it's slow locally and very slow in CI), so this switches to a different way to check if an IP is local, which should be equivalent (no changes needed to the tests).This also caches the allowed hosts once per process to make that part faster too (
_resolve_host_ips)AI disclosure: helped by Claude Opus 5.5
Fix #90
Fix #103