Hello,

I would like to have a metric that measures time spent for work (executing completion handlers) vs time spent waiting for work in thread pool executing io_context::run(). It will help to estimate service capacity (i.e. how many more requests per second it can handle). It is similar to the system's CPU usage metric but CPU usage metric does not include waiting for mutex locks or sync io performed from completion handlers. In our performance tests io_context becomes overloaded (the queue grows faster than it's processed) when CPU usage is about 85%. I would like to have a metric that shows 100% in this case.

There is BOOST_ASIO_CUSTOM_HANDLER_TRACKING macro that allows to intercept handler invocations and to measure execution time. But in the case of many lightweight handlers measuring time can bring significant overhead. I'm considering adding similar macros before and after waiting for the condition variable and epoll to measure wait time and then calculate execution time.

I'm writing to ask if there is a better alternative? If not, would you be interested in a patch that adds "Handler Tracking" macros around wait calls?

Thank you,
Dmitry