chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.84k stars 1.2k forks source link

Access to Internal Resolver Thread ID #1513

Open tarun-t opened 1 month ago

tarun-t commented 1 month ago

Description

Currently, there is no way to access the thread ID of the internal thread used by Asio for DNS resolution. This information could be valuable for debugging, logging, or performance analysis.

Current Behavior

Asio creates internal threads for certain operations, including name resolution. These threads perform DNS lookups asynchronously, but their thread IDs are not exposed through the public API.

Desired Behavior

It would be beneficial to have a method to retrieve the thread ID of the internal resolver thread. This could be implemented as:

A new method in the ip::tcp::resolver class A property of the io_context that manages these threads A callback that provides this information when a resolver operation is initiated

Use Case

Access to this thread ID would allow developers to:

Track and log which thread is handling DNS resolutions Set CPU affinity for these threads if desired

Questions

Is there a technical reason why this information is not currently exposed?

Additional Context

This limitation was discovered while attempting to track all threads involved in network operations within an application using Asio.

InternalHigh commented 1 month ago

It will prevent implementing DNS resolution without threads in the future. Maybe thread naming is a viable option.

BTW: @chriskohlhoff ignores issues