trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject [1/5] git commit: TS-2873 Cleanup SPDY metrics and configs
Date Wed, 04 Jun 2014 19:23:31 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/5.0.x 3b8c779fd -> 1b4e18699


TS-2873 Cleanup SPDY metrics and configs


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/cb2ca536
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/cb2ca536
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/cb2ca536

Branch: refs/heads/5.0.x
Commit: cb2ca536d7412e0207a09fd9d12507950540bffb
Parents: 2c757ab
Author: Leif Hedstrom <zwoop@apache.org>
Authored: Tue Jun 3 16:03:58 2014 -0600
Committer: Leif Hedstrom <zwoop@apache.org>
Committed: Tue Jun 3 16:04:02 2014 -0600

----------------------------------------------------------------------
 CHANGES                         |  3 ++
 proxy/spdy/SpdyCallbacks.cc     |  2 +-
 proxy/spdy/SpdyClientSession.cc | 22 ++++++------
 proxy/spdy/SpdyCommon.cc        | 38 ++++++++++++++-------
 proxy/spdy/SpdyCommon.h         | 66 +++++++++++++++---------------------
 5 files changed, 68 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb2ca536/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index b510d98..bff65b4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2873] Cleanup SPDY metrics and configs, also make it use the common
+   pattern for stats increments/decrements (even though it's ugly, sorry amc).
+
   *) [TS-2870] Update SPDY defaults to better match our other defaults.
 
   *) [TS-2868] Error setting HSTS max age with traffic_line

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb2ca536/proxy/spdy/SpdyCallbacks.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCallbacks.cc b/proxy/spdy/SpdyCallbacks.cc
index 59dd443..d565d09 100644
--- a/proxy/spdy/SpdyCallbacks.cc
+++ b/proxy/spdy/SpdyCallbacks.cc
@@ -406,7 +406,7 @@ spdy_on_data_recv_callback(spdylay_session *session, uint8_t flags,
   Debug("spdy", "----sm_id:%" PRId64 ", stream_id:%d, delta_window_size:%d",
         sm->sm_id, stream_id, req->delta_window_size);
 
-  if (req->delta_window_size >= SPDY_CFG.spdy.initial_window_size/2) {
+  if (req->delta_window_size >= spdy_initial_window_size/2) {
     Debug("spdy", "----Reenable write_vio for WINDOW_UPDATE frame, delta_window_size:%d",
           req->delta_window_size);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb2ca536/proxy/spdy/SpdyClientSession.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyClientSession.cc b/proxy/spdy/SpdyClientSession.cc
index 331362c..48477fa 100644
--- a/proxy/spdy/SpdyClientSession.cc
+++ b/proxy/spdy/SpdyClientSession.cc
@@ -60,14 +60,14 @@ SpdyRequest::init(SpdyClientSession *sm, int id)
   MD5_Init(&recv_md5);
   start_time = TShrtime();
 
-  SpdyStatIncrCount(Config::STAT_CURRENT_CLIENT_STREAM_COUNT, sm);
-  SpdyStatIncrCount(Config::STAT_TOTAL_CLIENT_STREAM_COUNT, sm);
+  SPDY_INCREMENT_THREAD_DYN_STAT(SPDY_STAT_CURRENT_CLIENT_STREAM_COUNT, sm->mutex->thread_holding);
+  SPDY_INCREMENT_THREAD_DYN_STAT(SPDY_STAT_TOTAL_CLIENT_STREAM_COUNT, sm->mutex->thread_holding);
 }
 
 void
 SpdyRequest::clear()
 {
-  SpdyStatDecrCount(Config::STAT_CURRENT_CLIENT_STREAM_COUNT, spdy_sm);
+  SPDY_DECREMENT_THREAD_DYN_STAT(SPDY_STAT_CURRENT_CLIENT_STREAM_COUNT, spdy_sm->mutex->thread_holding);
 
   if (fetch_sm)
     TSFetchDestroy(fetch_sm);
@@ -94,21 +94,21 @@ SpdyClientSession::init(NetVConnection * netvc, spdy::SessionVersion vers)
   this->req_map.clear();
   this->version = vers;
 
-  r = spdylay_session_server_new(&session, versmap[vers], &SPDY_CFG.spdy.callbacks,
this);
+  r = spdylay_session_server_new(&session, versmap[vers], &spdy_callbacks, this);
 
   // A bit ugly but we need a thread and I don't want to wait until the
   // session start event in case of a time out generating a decrement
   // with no increment. It seems a lesser thing to have the thread counts
   // a little off but globally consistent.
-  SpdyStatIncrCount(Config::STAT_CURRENT_CLIENT_SESSION_COUNT, netvc);
-  SpdyStatIncrCount(Config::STAT_TOTAL_CLIENT_CONNECTION_COUNT, netvc);
+  SPDY_INCREMENT_THREAD_DYN_STAT(SPDY_STAT_CURRENT_CLIENT_SESSION_COUNT, netvc->mutex->thread_holding);
+  SPDY_INCREMENT_THREAD_DYN_STAT(SPDY_STAT_TOTAL_CLIENT_CONNECTION_COUNT, netvc->mutex->thread_holding);
 
   ink_release_assert(r == 0);
   sm_id = atomic_inc(g_sm_id);
   total_size = 0;
   start_time = TShrtime();
 
-  this->vc->set_inactivity_timeout(HRTIME_SECONDS(SPDY_CFG.accept_no_activity_timeout));
+  this->vc->set_inactivity_timeout(HRTIME_SECONDS(spdy_accept_no_activity_timeout));
   SET_HANDLER(&SpdyClientSession::state_session_start);
 
 }
@@ -118,7 +118,7 @@ SpdyClientSession::clear()
 {
   int last_event = event;
 
-  SpdyStatDecrCount(Config::STAT_CURRENT_CLIENT_SESSION_COUNT, this);
+  SPDY_DECREMENT_THREAD_DYN_STAT(SPDY_STAT_CURRENT_CLIENT_SESSION_COUNT, this->mutex->thread_holding);
 
   //
   // SpdyRequest depends on SpdyClientSession,
@@ -208,7 +208,7 @@ SpdyClientSession::state_session_start(int /* event */, void * /* edata
*/)
 
   /* send initial settings frame */
   entry.settings_id = SPDYLAY_SETTINGS_MAX_CONCURRENT_STREAMS;
-  entry.value = SPDY_CFG.spdy.max_concurrent_streams;
+  entry.value = spdy_max_concurrent_streams;
   entry.flags = SPDYLAY_ID_FLAG_SETTINGS_NONE;
 
   r = spdylay_submit_settings(this->session, SPDYLAY_FLAG_SETTINGS_NONE, &entry, 1);
@@ -254,7 +254,7 @@ out:
     this->clear();
     spdyClientSessionAllocator.free(this);
   } else if (!from_fetch) {
-    this->vc->set_inactivity_timeout(HRTIME_SECONDS(SPDY_CFG.no_activity_timeout_in));
+    this->vc->set_inactivity_timeout(HRTIME_SECONDS(spdy_no_activity_timeout_in));
   }
 
   return EVENT_CONT;
@@ -399,7 +399,7 @@ spdy_read_fetch_body_callback(spdylay_session * /*session*/, int32_t stream_id,
   if (already < (int64_t)length) {
     if (req->event == TS_FETCH_EVENT_EXT_BODY_DONE) {
       TSHRTime end_time = TShrtime();
-      SpdyStatIncr(Config::STAT_TOTAL_TRANSACTIONS_TIME, sm, end_time - req->start_time);
+      SPDY_SUM_THREAD_DYN_STAT(SPDY_STAT_TOTAL_TRANSACTIONS_TIME, sm->mutex->thread_holding,
end_time - req->start_time);
       Debug("spdy", "----Request[%" PRIu64 ":%d] %s %lld %d", sm->sm_id, req->stream_id,
             req->url.c_str(), (end_time - req->start_time)/TS_HRTIME_MSECOND,
             req->fetch_data_len);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb2ca536/proxy/spdy/SpdyCommon.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCommon.cc b/proxy/spdy/SpdyCommon.cc
index 2adabdb..6647671 100644
--- a/proxy/spdy/SpdyCommon.cc
+++ b/proxy/spdy/SpdyCommon.cc
@@ -24,15 +24,24 @@
 #include "SpdyCommon.h"
 #include "SpdyCallbacks.h"
 
-Config SPDY_CFG;
+// SPDYlay callbacks
+spdylay_session_callbacks spdy_callbacks;
 
 // statistic names
+RecRawStatBlock* spdy_rsb; ///< Container for statistics.
+
 static char const * const SPDY_STAT_CURRENT_CLIENT_SESSION_NAME = "proxy.process.spdy.current_client_sessions";
 static char const * const SPDY_STAT_CURRENT_CLIENT_STREAM_NAME = "proxy.process.spdy.current_client_streams";
 static char const * const SPDY_STAT_TOTAL_CLIENT_STREAM_NAME = "proxy.process.spdy.total_client_streams";
 static char const * const SPDY_STAT_TOTAL_TRANSACTIONS_TIME_NAME = "proxy.process.spdy.total_transactions_time";
 static char const * const SPDY_STAT_TOTAL_CLIENT_CONNECTION_NAME = "proxy.process.spdy.total_client_connections";
 
+// Configurations
+int32_t spdy_max_concurrent_streams = 100;
+int32_t spdy_initial_window_size = 65536;
+int32_t spdy_accept_no_activity_timeout = 120;
+int32_t spdy_no_activity_timeout_in = 115;
+
 string
 http_date(time_t t)
 {
@@ -45,20 +54,25 @@ http_date(time_t t)
 int
 spdy_config_load()
 {
-  REC_EstablishStaticConfigInt32(SPDY_CFG.spdy.max_concurrent_streams, "proxy.config.spdy.max_concurrent_streams_in");
-  REC_EstablishStaticConfigInt32(SPDY_CFG.no_activity_timeout_in, "proxy.config.spdy.no_activity_timeout_in");
-  REC_EstablishStaticConfigInt32(SPDY_CFG.accept_no_activity_timeout, "proxy.config.spdy.accept_no_activity_timeout");
-  REC_EstablishStaticConfigInt32(SPDY_CFG.spdy.initial_window_size, "proxy.config.spdy.initial_window_size_in");
+  REC_EstablishStaticConfigInt32(spdy_max_concurrent_streams, "proxy.config.spdy.max_concurrent_streams_in");
+  REC_EstablishStaticConfigInt32(spdy_no_activity_timeout_in, "proxy.config.spdy.no_activity_timeout_in");
+  REC_EstablishStaticConfigInt32(spdy_accept_no_activity_timeout, "proxy.config.spdy.accept_no_activity_timeout");
+  REC_EstablishStaticConfigInt32(spdy_initial_window_size, "proxy.config.spdy.initial_window_size_in");
 
-  spdy_callbacks_init(&SPDY_CFG.spdy.callbacks);
+  spdy_callbacks_init(&spdy_callbacks);
 
   // Get our statistics up
-  SPDY_CFG.rsb = RecAllocateRawStatBlock(static_cast<int>(Config::N_STATS));
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_CURRENT_CLIENT_SESSION_NAME, RECD_INT,
RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_CURRENT_CLIENT_SESSION_COUNT), RecRawStatSyncCount);
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_CURRENT_CLIENT_STREAM_NAME, RECD_INT,
RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_CURRENT_CLIENT_STREAM_COUNT), RecRawStatSyncCount);
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_CLIENT_STREAM_NAME, RECD_INT,
RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_CLIENT_STREAM_COUNT), RecRawStatSyncCount);
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_TRANSACTIONS_TIME_NAME,
RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_TRANSACTIONS_TIME),
RecRawStatSyncSum);
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_CLIENT_CONNECTION_NAME,
RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_CLIENT_CONNECTION_COUNT),
RecRawStatSyncCount);
+  spdy_rsb = RecAllocateRawStatBlock(static_cast<int>(SPDY_N_STATS));
+  RecRegisterRawStat(spdy_rsb, RECT_PROCESS, SPDY_STAT_CURRENT_CLIENT_SESSION_NAME, RECD_INT,
RECP_NON_PERSISTENT,
+                     static_cast<int>(SPDY_STAT_CURRENT_CLIENT_SESSION_COUNT), RecRawStatSyncSum);
+  RecRegisterRawStat(spdy_rsb, RECT_PROCESS, SPDY_STAT_CURRENT_CLIENT_STREAM_NAME, RECD_INT,
RECP_NON_PERSISTENT,
+                     static_cast<int>(SPDY_STAT_CURRENT_CLIENT_STREAM_COUNT), RecRawStatSyncSum);
+  RecRegisterRawStat(spdy_rsb, RECT_PROCESS, SPDY_STAT_TOTAL_CLIENT_STREAM_NAME, RECD_INT,
RECP_NON_PERSISTENT,
+                     static_cast<int>(SPDY_STAT_TOTAL_CLIENT_STREAM_COUNT), RecRawStatSyncSum);
+  RecRegisterRawStat(spdy_rsb, RECT_PROCESS, SPDY_STAT_TOTAL_TRANSACTIONS_TIME_NAME, RECD_INT,
RECP_NON_PERSISTENT,
+                     static_cast<int>(SPDY_STAT_TOTAL_TRANSACTIONS_TIME), RecRawStatSyncSum);
+  RecRegisterRawStat(spdy_rsb, RECT_PROCESS, SPDY_STAT_TOTAL_CLIENT_CONNECTION_NAME, RECD_INT,
RECP_NON_PERSISTENT,
+                     static_cast<int>(SPDY_STAT_TOTAL_CLIENT_CONNECTION_COUNT), RecRawStatSyncSum);
 
   return 0;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb2ca536/proxy/spdy/SpdyCommon.h
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCommon.h b/proxy/spdy/SpdyCommon.h
index 61a8234..02e4a50 100644
--- a/proxy/spdy/SpdyCommon.h
+++ b/proxy/spdy/SpdyCommon.h
@@ -55,29 +55,26 @@ using namespace std;
 #define atomic_inc(a)   atomic_fetch_and_add(a, 1)
 #define atomic_dec(a)   atomic_fetch_and_sub(a, 1)
 
-struct SpdyConfig {
-  int32_t max_concurrent_streams;
-  int32_t initial_window_size;
-  spdylay_session_callbacks callbacks;
-};
-
-struct Config {
-  SpdyConfig spdy;
-  int32_t accept_no_activity_timeout;
-  int32_t no_activity_timeout_in;
-
-  // Statistics
-  /// This is the stat slot index for each statistic.
-  enum StatIndex {
-    STAT_CURRENT_CLIENT_SESSION_COUNT, ///< Current # of active SPDY sessions.
-    STAT_CURRENT_CLIENT_STREAM_COUNT, ///< Current # of active SPDY streams.
-    STAT_TOTAL_CLIENT_STREAM_COUNT, ///< Total number of streams created.
-    STAT_TOTAL_TRANSACTIONS_TIME,  //< Total stream time
-    STAT_TOTAL_CLIENT_CONNECTION_COUNT, //< Total connections running spdy
-
-    N_STATS ///< Terminal counter, NOT A STAT INDEX.
-  };
-  RecRawStatBlock* rsb; ///< Container for statistics.
+// SPDYlay callbacks
+extern spdylay_session_callbacks spdy_callbacks;
+
+// Configurations
+extern int32_t spdy_max_concurrent_streams;
+extern int32_t spdy_initial_window_size;
+extern int32_t spdy_accept_no_activity_timeout;
+extern int32_t spdy_no_activity_timeout_in;
+
+// Statistics
+extern RecRawStatBlock* spdy_rsb;
+
+enum {
+  SPDY_STAT_CURRENT_CLIENT_SESSION_COUNT, ///< Current # of active SPDY sessions.
+  SPDY_STAT_CURRENT_CLIENT_STREAM_COUNT, ///< Current # of active SPDY streams.
+  SPDY_STAT_TOTAL_CLIENT_STREAM_COUNT, ///< Total number of streams created.
+  SPDY_STAT_TOTAL_TRANSACTIONS_TIME,  //< Total stream time
+  SPDY_STAT_TOTAL_CLIENT_CONNECTION_COUNT, //< Total connections running spdy
+
+  SPDY_N_STATS ///< Terminal counter, NOT A STAT INDEX.
 };
 
 // Spdy Name/Value pairs
@@ -100,23 +97,14 @@ private:
 string http_date(time_t t);
 int spdy_config_load();
 
-extern Config SPDY_CFG;
-
-// Stat helper functions
-
-inline void
-SpdyStatIncrCount(Config::StatIndex idx, Continuation* contp) {
-  RecIncrRawStatCount(SPDY_CFG.rsb, contp->mutex->thread_holding, idx, 1);
-}
+// Stat helper functions. ToDo: These probably should be turned into #define's as we do elsewhere
+#define SPDY_INCREMENT_THREAD_DYN_STAT(_s, _t)     \
+  RecIncrRawStat(spdy_rsb, _t, (int) _s, 1);
 
-inline void
-SpdyStatDecrCount(Config::StatIndex idx, Continuation* contp) {
-  RecIncrRawStatCount(SPDY_CFG.rsb, contp->mutex->thread_holding, idx, -1);
-}
+#define SPDY_DECREMENT_THREAD_DYN_STAT(_s, _t)     \
+  RecIncrRawStat(spdy_rsb, _t, (int) _s, -1);
 
-inline void
-SpdyStatIncr(Config::StatIndex idx, Continuation* contp, const int64_t incr) {
-  RecIncrRawStat(SPDY_CFG.rsb, contp->mutex->thread_holding, idx, incr);
-}
+#define SPDY_SUM_THREAD_DYN_STAT(_s, _t, _v)       \
+  RecIncrRawStat(spdy_rsb, _t, (int) _s, _v);
 
 #endif


Mime
View raw message