-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
net: DNS Lookups Very Slow (netgo) #49253
Comments
What’s the result that is resolved after 5 seconds? I have a suspicion that’s a timeout. |
The main problem is with cross-compiling, there doesn't seem to be a way to cross-compile a working version of this code as it always uses the extremely slow Go resolver. |
That is correct, cgo is disabled when cross compiling. |
@ianlancetaylor @neild per owners. |
A request: please put plain text as plain text in comments. Please do not use images. Plain text is much easier to read, and permits cut and paste. Thanks. |
You can enable cgo when cross-compiling, but you must have a C cross-compiler. Set the environment variable |
Are you running the program on amd64 darwin? |
Yes, |
Running your test program on my OS X laptop:
I don't know why resolution is taking 5 seconds on your machine, but it's not fundamental to the Go resolver. The very round value of 5 seconds is quite suspicious. |
Yes, it does seem environmental, but the oddity is that |
Okay I think I figured it out: pure go resolver relies on |
The five seconds look like some of the defaults we have in the net package: Line 43 in c45c32b
What does your resolv.conf look like? If it has multiple entries, I wonder if one entry is hitting the 5s timeout, then the next entry correctly resolves. |
Oops, comment race. I still wonder if there's something to do in the net package. It's technically right, but taking five seconds to give a good result is not intuitive at all. |
@mvdan Sorry for the bump, but I identified this exact issue and was looking into whether it needed to be reported when I ran into this report. Should this be reopened? I've had to stop using Mac cross-compilation for some code that runs into this because of the five second delay. |
@mistydemeo at least OP's problem seemed to stem from a bad resolv.conf - do you have a similar situation? If the system resolver is faster or more reliable in these situations, I think it would be reasonable to reopen the issue as an enhancement. |
Thanks @seankhliao; it seems like #12524 is the proper fix. |
It's #12524. In my case, it's caused by a VPN-provided resolver that's not in A comment from 2018 indicated it wasn't considered a big deal to build for Darwin on Darwin, but cross-compilation for Intel/ARM64 binaries has made this something much easier to run into consistently even when building for Darwin on Darwin. |
Indeed, and I don't think anyone is disputing that #12524 should happen. I believe the labels "help wanted" and "needs investigation" roughly mean "this requires some expertise and time, and we lack either at the moment". |
It doesn't looks like the Go's DNS resolver slow issue related only to darwin, since I stepped today on the same issue on a plain Linux machine. All network tools like Go program compiled with
gave me back query time between 1.9-2.2 seconds for the After reducing
everything get back to "normal" and Go's resolver resolves It looks like Go's reads the whole I believe such "issue" (huge I actually hesitating to call discovered behavior as an issue unless someone figure how it can be improved. |
What version of Go are you using (
go version
)?Possible duplicate/regression of #21906 and or #26960
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?
Example code: https://gist.github.com/moloch--/7ffa9548b3c0f826b39533fcde7e1105
PreferGo
seems to be ignored when cross-compiling, somewhat expected but extremely un-intuitive.What did you expect to see?
DNS queries should take around the same time as the system resolver.
What did you see instead?
It takes Go 5+ seconds to resolve a domain.
The text was updated successfully, but these errors were encountered: