@@ -70,6 +70,8 @@ nlohmann::json ClientConnectionDetails::to_json(
7070 */
7171static std::vector<FrontEndThread> threads;
7272std::vector<Hdr1sfMicroSecHistogram> scheduler_info;
73+ std::vector<Hdr1sfMicroSecHistogram> dispatch_socket_histogram;
74+ std::vector<Hdr1sfMicroSecHistogram> cookie_notification_histogram;
7375
7476/*
7577 * Number of worker threads that have finished setting themselves up.
@@ -307,11 +309,14 @@ void FrontEndThread::do_dispatch(SOCKET sfd,
307309 associate_initial_bucket (*c);
308310 success = true ;
309311 } catch (const std::bad_alloc&) {
310- LOG_WARNING_RAW (" Failed to allocate memory for connection" );
312+ LOG_WARNING_CTX (" Failed to allocate memory for connection" ,
313+ {" worker_tid" , index});
311314 } catch (const std::exception& error) {
312- LOG_WARNING_CTX (" Failed to create connection" , {" error" , error.what ()});
315+ LOG_WARNING_CTX (" Failed to create connection" ,
316+ {" error" , error.what ()},
317+ {" worker_tid" , index});
313318 } catch (...) {
314- LOG_WARNING_RAW (" Failed to create connection" );
319+ LOG_WARNING_CTX (" Failed to create connection" , { " worker_tid " , index} );
315320 }
316321
317322 if (!success) {
@@ -380,8 +385,13 @@ void FrontEndThread::dispatch(SOCKET sfd,
380385 last_thread = tid;
381386
382387 try {
383- thread.eventBase .runInEventBaseThread (
384- [&thread, sock = sfd, port = std::move (descr)]() {
388+ using namespace std ::chrono;
389+ const auto scheduled = steady_clock::now ();
390+ thread.eventBase .runInEventBaseThreadAlwaysEnqueue (
391+ [&thread, sock = sfd, port = std::move (descr), scheduled]() {
392+ const auto now = steady_clock::now ();
393+ dispatch_socket_histogram[thread.index ].add (
394+ duration_cast<microseconds>(now - scheduled));
385395 thread.do_dispatch (sock, port);
386396 });
387397 } catch (const std::bad_alloc& e) {
@@ -428,6 +438,8 @@ void worker_threads_init() {
428438 const auto nthr = Settings::instance ().getNumWorkerThreads ();
429439
430440 scheduler_info.resize (nthr);
441+ dispatch_socket_histogram.resize (nthr);
442+ cookie_notification_histogram.resize (nthr);
431443
432444 try {
433445 threads = std::vector<FrontEndThread>(nthr);
0 commit comments