You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by su...@apache.org on 2020/06/12 05:30:09 UTC

[trafficserver] branch master updated: Track thread changes during origin connect and cache open write (#6872)

This is an automated email from the ASF dual-hosted git repository.

sudheerv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 59c5e25  Track thread changes during origin connect and cache open write (#6872)
59c5e25 is described below

commit 59c5e25846b0dfe8720b5027fecac72af2da1545
Author: Sudheer Vinukonda <su...@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
---
 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 3f824e0..9be892f 100644
--- a/proxy/ProxyTransaction.cc
+++ b/proxy/ProxyTransaction.cc
@@ -83,23 +83,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 4f00b34..0c51d04 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 ed0fcce..980c629 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -328,6 +328,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 6dfbe23..323564f 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -2451,6 +2451,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
     }
   }
@@ -4818,6 +4819,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
     }
   }