This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.0.x by this push: new d821bbe Track thread changes during origin connect and cache open write (#6872) d821bbe is described below commit d821bbebef4807c7b47661ad67f37cc7db0e3ce7 Author: Sudheer Vinukonda <sudhe...@apache.org> AuthorDate: Thu Jun 11 22:29:57 2020 -0700 Track thread changes during origin connect and cache open write (#6872) Also make adjust_thread() inline as an optimization (cherry picked from commit 59c5e25846b0dfe8720b5027fecac72af2da1545) --- proxy/ProxyTransaction.cc | 17 ----------------- proxy/ProxyTransaction.h | 17 +++++++++++++++++ proxy/http/HttpConfig.cc | 6 ++++++ proxy/http/HttpConfig.h | 3 +++ proxy/http/HttpSM.cc | 2 ++ 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/proxy/ProxyTransaction.cc b/proxy/ProxyTransaction.cc index 8042c34..23eeb08 100644 --- a/proxy/ProxyTransaction.cc +++ b/proxy/ProxyTransaction.cc @@ -80,23 +80,6 @@ ProxyTransaction::destroy() this->mutex.clear(); } -// See if we need to schedule on the primary thread for the transaction or change the thread that is associated with the VC. -// If we reschedule, the scheduled action is returned. Otherwise, NULL is returned -Action * -ProxyTransaction::adjust_thread(Continuation *cont, int event, void *data) -{ - NetVConnection *vc = this->get_netvc(); - EThread *this_thread = this_ethread(); - if (vc && vc->thread != this_thread) { - if (vc->thread->is_event_type(ET_NET)) { - return vc->thread->schedule_imm(cont, event, data); - } else { // Not a net thread, take over this thread - vc->thread = this_thread; - } - } - return nullptr; -} - void ProxyTransaction::set_rx_error_code(ProxyError e) { diff --git a/proxy/ProxyTransaction.h b/proxy/ProxyTransaction.h index 51f35db..83a2111 100644 --- a/proxy/ProxyTransaction.h +++ b/proxy/ProxyTransaction.h @@ -221,3 +221,20 @@ ProxyTransaction::support_sni() const { return _proxy_ssn ? _proxy_ssn->support_sni() : false; } + +// See if we need to schedule on the primary thread for the transaction or change the thread that is associated with the VC. +// If we reschedule, the scheduled action is returned. Otherwise, NULL is returned +inline Action * +ProxyTransaction::adjust_thread(Continuation *cont, int event, void *data) +{ + NetVConnection *vc = this->get_netvc(); + EThread *this_thread = this_ethread(); + if (vc && vc->thread != this_thread) { + if (vc->thread->is_event_type(ET_NET)) { + return vc->thread->schedule_imm(cont, event, data); + } else { // Not a net thread, take over this thread + vc->thread = this_thread; + } + } + return nullptr; +} diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index 0ec5251..ebe0886 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -942,6 +942,12 @@ register_stat_callbacks() (int)http_origin_connections_throttled_stat, RecRawStatSyncCount); RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.post_body_too_large", RECD_COUNTER, RECP_PERSISTENT, (int)http_post_body_too_large, RecRawStatSyncCount); + RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.connect.adjust_thread", RECD_COUNTER, RECP_NON_PERSISTENT, + (int)http_origin_connect_adjust_thread_stat, RecRawStatSyncCount); + HTTP_CLEAR_DYN_STAT(http_origin_connect_adjust_thread_stat); + RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache.open_write.adjust_thread", RECD_COUNTER, RECP_NON_PERSISTENT, + (int)http_cache_open_write_adjust_thread_stat, RecRawStatSyncCount); + HTTP_CLEAR_DYN_STAT(http_cache_open_write_adjust_thread_stat); // milestones RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.ua_begin", RECD_COUNTER, RECP_PERSISTENT, (int)http_ua_begin_time_stat, RecRawStatSyncSum); diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index 978775d..7c6eb7a 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -327,6 +327,9 @@ enum { http_origin_connections_throttled_stat, + http_origin_connect_adjust_thread_stat, + http_cache_open_write_adjust_thread_stat, + http_stat_count }; diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 04bee2f..105180b 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -2405,6 +2405,7 @@ HttpSM::state_cache_open_write(int event, void *data) pending_action->cancel(); } if ((pending_action = ua_txn->adjust_thread(this, event, data))) { + HTTP_INCREMENT_DYN_STAT(http_cache_open_write_adjust_thread_stat); return 0; // Go away if we reschedule } } @@ -4780,6 +4781,7 @@ HttpSM::do_http_server_open(bool raw) // Make sure we are on the "right" thread if (ua_txn) { if ((pending_action = ua_txn->adjust_thread(this, EVENT_INTERVAL, nullptr))) { + HTTP_INCREMENT_DYN_STAT(http_origin_connect_adjust_thread_stat); return; // Go away if we reschedule } }