fix: Slow DNS lookups on (at least) Windows by updating to main of Hickory (#3799)

```[tasklist]
- [x] Maybe pick a rev for Hickory so even if Cargo.lock is rebuilt we don't advance unless we want to
- [ ] Maybe ask them politely to cut a release with this patch since it helps us
```

Tested on my Windows laptop and it reduces `nslookup` times for
resources and non-resources (can't remember which way was which) from
something like 10 and 2 seconds to 0.25 and 0.33 seconds, which is
great.

Hickory's patch got merged into main around Jan 5th but they haven't cut
a release since then, so this PR changes us to use Hickory's main branch
instead of crates.io:
https://github.com/hickory-dns/hickory-dns/issues/2081
This commit is contained in:
Reactor Scram
2024-02-28 13:35:07 -06:00
committed by GitHub
parent 2f72e225f8
commit bb4a170ca5
3 changed files with 15 additions and 22 deletions

20
rust/Cargo.lock generated
View File

@@ -2605,8 +2605,7 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46"
[[package]]
name = "hickory-proto"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "091a6fbccf4860009355e3efc52ff4acf37a63489aad7435372d44ceeb6fbbcf"
source = "git+https://github.com/hickory-dns/hickory-dns?rev=a3669bd80f3f7b97f0c301c15f1cba6368d97b63#a3669bd80f3f7b97f0c301c15f1cba6368d97b63"
dependencies = [
"async-trait",
"cfg-if",
@@ -2615,7 +2614,7 @@ dependencies = [
"futures-channel",
"futures-io",
"futures-util",
"idna 0.4.0",
"idna",
"ipnet",
"once_cell",
"rand 0.8.5",
@@ -2629,8 +2628,7 @@ dependencies = [
[[package]]
name = "hickory-resolver"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35b8f021164e6a984c9030023544c57789c51760065cd510572fedcfb04164e8"
source = "git+https://github.com/hickory-dns/hickory-dns?rev=a3669bd80f3f7b97f0c301c15f1cba6368d97b63#a3669bd80f3f7b97f0c301c15f1cba6368d97b63"
dependencies = [
"cfg-if",
"futures-util",
@@ -2903,16 +2901,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c"
dependencies = [
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "idna"
version = "0.5.0"
@@ -6898,7 +6886,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
dependencies = [
"form_urlencoded",
"idna 0.5.0",
"idna",
"percent-encoding",
"serde",
]

View File

@@ -25,7 +25,7 @@ backoff = { version = "0.4", features = ["tokio"] }
tracing = { version = "0.1.40" }
tracing-subscriber = { version = "0.3.17", features = ["parking_lot"] }
secrecy = "0.8"
hickory-resolver = { version = "0.24", features = ["tokio-runtime"] }
hickory-resolver = { git = "https://github.com/hickory-dns/hickory-dns", rev="a3669bd80f3f7b97f0c301c15f1cba6368d97b63", features = ["tokio-runtime"] }
str0m = { version = "0.4", default-features = false }
futures-bounded = "0.2.1"
domain = { version = "0.9", features = ["serde"] }

View File

@@ -9,6 +9,7 @@ use domain::base::{
Message, MessageBuilder, Question, ToDname,
};
use hickory_resolver::lookup::Lookup;
use hickory_resolver::proto::error::{ProtoError, ProtoErrorKind};
use hickory_resolver::proto::op::{Message as TrustDnsMessage, MessageType};
use hickory_resolver::proto::rr::RecordType;
use itertools::Itertools;
@@ -166,11 +167,15 @@ pub(crate) fn build_response_from_resolve_result(
let response = match response.map_err(|err| err.kind().clone()) {
Ok(response) => message.add_answers(response.records().to_vec()),
Err(hickory_resolver::error::ResolveErrorKind::NoRecordsFound {
soa,
response_code,
..
}) => {
Err(hickory_resolver::error::ResolveErrorKind::Proto(ProtoError { kind, .. }))
if matches!(*kind, ProtoErrorKind::NoRecordsFound { .. }) =>
{
let ProtoErrorKind::NoRecordsFound {
soa, response_code, ..
} = *kind
else {
panic!("Impossible - We matched on `ProtoErrorKind::NoRecordsFound` but then could not destructure that same variant");
};
if let Some(soa) = soa {
message.add_name_server(soa.clone().into_record_of_rdata());
}