net: unexpected slowness with cgo resolving a domain that is manually added to /etc/hosts on Darwin #63428
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
OS-Darwin
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Modify /etc/hosts to contain the following line:
Then have a tiny Go module:
Then:
What did you expect to see?
This to be quick.
What did you see instead?
This is slow -- always >5s.
If you use GODEBUG=netdns=go, this is fast.
I was debugging the difference between how librdkafka uses getaddr info and how Go uses getaddrinfo.
librdkafka uses a single flag,
AI_ADDRCONFIG
. Go uses this const which, with the mask, ends up beingAI_CANONNAME
.If I change this line to 0x400 to match AI_ADDRCONFIG, the cgo resolver is fast.
I don't really understand the ramifications of the 0x1407 mask, nor which flag should be used when -- but it is odd that this specific single flag that is used forces getaddrinfo to always take 5s, whereas a different flag incantation is fast (and the pure Go resolver is also fast).
Please close this issue if this cannot be / wont be addressed, but I hope this is enough information to go on and to potentially fix something.
The text was updated successfully, but these errors were encountered: