mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[GH-ISSUE #1260] Question / Feature: Shared Trust-DNS and Runtime(tokio/*) #637
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#637
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JRAndreassen on GitHub (Oct 21, 2020).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1260
Hi...
I have a couple of questions regarding instantiating Trust-DNS in a app using Tokio...
Is there a way to tell Trust-DNS to use the "Current" runtime ?
Since there is already a Tokio instance running, creating another seems a bit excessive.
(Perhaps use the current and add a few worker threads to it).
It would be a great addon to Tokio 0.3.0 [#1250]
My application relies on reqwest , which also uses trust-dns...
Is there a way to share this instance ?
As it goes, I have 3-tokio runtimes and 2 Trust-DNS instances running
@bluejekyll commented on GitHub (Oct 21, 2020):
To get access to the current Runtime in Tokio, there is this method in 0.2: https://docs.rs/tokio/0.2.22/tokio/runtime/struct.Handle.html#method.current
I believe in tokio 0.3, this method will be the only way, as handle has been removed: https://docs.rs/tokio/0.3.0/tokio/fn.spawn.html
@JRAndreassen commented on GitHub (Oct 21, 2020):
@bluejekyll 👍
Thanks for responding...
I tried the handle approach... It did not like it...
It complained about no runtime... at least in the test...
I'll try again in the full run mode...
Yes, I noticed the handle being gone (I had to back off to "0.2"...)
Perhaps the option of passing in a runtime would work and Trust-DNS can spawn what it needs...
TokioAsyncResolver::new(ResolverConfig::quad9(), ResolverOpts::default(), &runtime)
Just a thought...
Thanks
JR
@JRAndreassen commented on GitHub (Oct 21, 2020):
Hi…
Yes, I saw the issue to move it forward to 0.3.0…
I’ll be looking out for it, when it is finished…
I did a quick test, using the handle.spawn…
It got stuck somewhere…
I’ll have to chase it later…
Thanks for responding…
JR
From: Benjamin Fry notifications@github.com
Sent: Wednesday, October 21, 2020 9:53 AM
To: bluejekyll/trust-dns trust-dns@noreply.github.com
Cc: JR Andreassen janrune@theandreassens.net; Author author@noreply.github.com
Subject: Re: [bluejekyll/trust-dns] Question / Feature: Shared Trust-DNS and Runtime(tokio/*) (#1260)
To be clear, trust-dns does not yet support Tokio 0.3.
You will need a Runtime associated to the current thread. This can be done in many ways, but the simples is to have a single point where you spawn all the futures.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/bluejekyll/trust-dns/issues/1260#issuecomment-713635267 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA5BTHAVNKIG3IVWIZIPBTSL3YWHANCNFSM4SZ2YVSA . https://github.com/notifications/beacon/ACA5BTCHACIGL3DCXNIWVF3SL3YWHA5CNFSM4SZ2YVSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFKETLQY.gif
@djc commented on GitHub (Oct 23, 2020):
I found this bug report a bit vague on the details. How do you notice that you have 3 tokio runtimes and 2 trust-dns instances running? What do you mean by "instances"? Why is having these instantiated a problem for you?
At least for trust-dns-resolver, it doesn't look like
AsyncResolverwill start its own runtime, so sharing a tokio runtime with other tasks seems fairly straightforward. Can you share some of your application code, or, preferably, a reduced code sample that leads to running 3 tokio runtimes and 2 trust-dns instances?It does look a little unfortunate that reqwest doesn't give you access to the trust-dns resolver it is using, or a way to configure it, which might be nice, but that would probably require some work on the reqwest side.
@JRAndreassen commented on GitHub (Oct 23, 2020):
@djc :
Well, I'm sorry... Did not mean to be "vague"...
Regarding the instances..:
By default, a tokio runtime will create 1 thread per core... Right...
My machine has 16-cores...
The application, running in production mode has 78 threads....
Though I can't give you the definitive proof, without doing a lot of work,
I think it is fairly safe to say, there is at least 3 Tokio runtimes active...
I will however create a sample (modify #1259 ) with a Reqwest client in addition to the sample above...
Edit: After some more digging...
40 of the threads were caused by wmi-rs, crate...
There are still at least 2 runtimes...
But, I'll keep digging...
JR
@djc commented on GitHub (Oct 24, 2020):
If you have
#[tokio::main]or#[tokio::test(core_threads = 4)], there's no need to start a runtime explicitly, why are you doing so?@JRAndreassen commented on GitHub (Oct 24, 2020):
@djc
Well, I tried to spawn with handle and pass it, but it paniced with a "No runtime"..
I guess the question I should ask is:
What is the correct way to spawn trust-dns when already running in a tokio context ?
I appreciate the pointer's...
JR
@bluejekyll commented on GitHub (Oct 24, 2020):
@JRAndreassen, what is it that you want to do? The answer to your question depends a bit on how you plan to use the library.
@JRAndreassen commented on GitHub (Oct 25, 2020):
@bluejekyll ...
It's pretty straight forward and reverse lookups...
I'm using it to time forward resolutions and reverse for display.
So, nothing fancy, just everyday lookups..
I do need to have a "Global" handle since there will be a lot of threads running...
(See #1259 )
I appreciate the assistance.
JR
@JRAndreassen commented on GitHub (Oct 25, 2020):
I got it to work...
See #1259