You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2010/09/28 17:44:32 UTC

svn commit: r1002226 - in /trafficserver/traffic/trunk: configure.ac libinktomi++/ink_config.h.in librecords/P_RecCore.h librecords/P_RecDefs.h librecords/RecCore.cc librecords/RecUtils.cc proxy/InkAPI.cc

Author: zwoop
Date: Tue Sep 28 15:44:31 2010
New Revision: 1002226

URL: http://svn.apache.org/viewvc?rev=1002226&view=rev
Log:
TS-454 Replace the dynamic size with a compile time option.

Since we'll replace the config system (hopefully) at some point,
I'm just going to simplify this and make the size compile time
defined (default is 512 slots for plugin stats, which is a lot).

The configure option is

      --with-max-api-stats    max number of plugin stats [default=512]

Modified:
    trafficserver/traffic/trunk/configure.ac
    trafficserver/traffic/trunk/libinktomi++/ink_config.h.in
    trafficserver/traffic/trunk/librecords/P_RecCore.h
    trafficserver/traffic/trunk/librecords/P_RecDefs.h
    trafficserver/traffic/trunk/librecords/RecCore.cc
    trafficserver/traffic/trunk/librecords/RecUtils.cc
    trafficserver/traffic/trunk/proxy/InkAPI.cc

Modified: trafficserver/traffic/trunk/configure.ac
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/configure.ac?rev=1002226&r1=1002225&r2=1002226&view=diff
==============================================================================
--- trafficserver/traffic/trunk/configure.ac (original)
+++ trafficserver/traffic/trunk/configure.ac Tue Sep 28 15:44:31 2010
@@ -372,6 +372,16 @@ AC_ARG_ENABLE([tproxy],
 AC_MSG_RESULT([$enable_tproxy])
 
 #
+# Configure how many stats to allocate for plugins. Default is 512.
+#
+AC_ARG_WITH([max-api-stats],
+  [AS_HELP_STRING([--with-max-api-stats],[max number of plugin stats [default=512]])],
+  [max_api_stats=$withval],
+  [max_api_stats=512]
+)
+AC_SUBST(max_api_stats)
+
+#
 # Installation directories
 # For each var the following is evaluated
 # foo      Standard variable  eg. ${prefix}/foo

Modified: trafficserver/traffic/trunk/libinktomi++/ink_config.h.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/libinktomi%2B%2B/ink_config.h.in?rev=1002226&r1=1002225&r2=1002226&view=diff
==============================================================================
--- trafficserver/traffic/trunk/libinktomi++/ink_config.h.in (original)
+++ trafficserver/traffic/trunk/libinktomi++/ink_config.h.in Tue Sep 28 15:44:31 2010
@@ -152,6 +152,7 @@
 #endif
 
 #if ATS_HAS_INKAPI
+#define TS_MAX_API_STATS               @max_api_stats@
 /* XXX: Should make those individually selectable ? */
 #else
 # define INK_NO_TRANSFORM               1

Modified: trafficserver/traffic/trunk/librecords/P_RecCore.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/P_RecCore.h?rev=1002226&r1=1002225&r2=1002226&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/P_RecCore.h (original)
+++ trafficserver/traffic/trunk/librecords/P_RecCore.h Tue Sep 28 15:44:31 2010
@@ -39,7 +39,6 @@ extern RecRecord *g_records;
 extern InkHashTable *g_records_ht;
 extern ink_rwlock g_records_rwlock;
 extern int g_num_records;
-extern int g_max_records;
 extern int g_num_update[];
 extern RecTree *g_records_tree;
 

Modified: trafficserver/traffic/trunk/librecords/P_RecDefs.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/P_RecDefs.h?rev=1002226&r1=1002225&r2=1002226&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/P_RecDefs.h (original)
+++ trafficserver/traffic/trunk/librecords/P_RecDefs.h Tue Sep 28 15:44:31 2010
@@ -35,10 +35,10 @@
 
 #define REC_MESSAGE_ELE_MAGIC           0xF00DF00D
 
-// This is for the internal stats and configs, API stats are additional (records.config)
-// TODO: For now, also allow for 1500 plugin stats, later this needs to be dynamically
-// resized, but not working right now.
-#define REC_MAX_RECORDS                 3000
+// This is for the internal stats and configs, as well as API stats. We currently use
+// about 1600 stats + configs for the core, but we're allocating 2000 for some growth.
+// TODO: if/when we switch to a new config system, we should make this run-time dynamic.
+#define REC_MAX_RECORDS                 (2000 + TS_MAX_API_STATS)
 
 #define REC_CONFIG_UPDATE_INTERVAL_SEC  3
 #define REC_REMOTE_SYNC_INTERVAL_SEC    5

Modified: trafficserver/traffic/trunk/librecords/RecCore.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/RecCore.cc?rev=1002226&r1=1002225&r2=1002226&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/RecCore.cc (original)
+++ trafficserver/traffic/trunk/librecords/RecCore.cc Tue Sep 28 15:44:31 2010
@@ -37,7 +37,6 @@ RecRecord *g_records = NULL;
 InkHashTable *g_records_ht = NULL;
 ink_rwlock g_records_rwlock;
 int g_num_records = 0;
-int g_max_records = 0;
 
 const char *g_rec_config_fpath = NULL;
 LLQ *g_rec_config_contents_llq = NULL;
@@ -181,12 +180,11 @@ RecCoreInit(RecModeT mode_type, Diags *_
   ink_atomic_swap_ptr(&g_diags, _diags);
 
   g_records_tree = new RecTree(NULL);
-  g_max_records = REC_MAX_RECORDS;
   g_num_records = 0;
 
   // initialize record array for our internal stats (this can be reallocated later)
-  g_records = (RecRecord *) xmalloc(g_max_records * sizeof(RecRecord));
-  memset(g_records, 0, g_max_records * sizeof(RecRecord));
+  g_records = (RecRecord *) xmalloc(REC_MAX_RECORDS * sizeof(RecRecord));
+  memset(g_records, 0, REC_MAX_RECORDS * sizeof(RecRecord));
 
   // initialize record hash index
   g_records_ht = ink_hash_table_create(InkHashTableKeyType_String);
@@ -236,29 +234,6 @@ RecCoreInit(RecModeT mode_type, Diags *_
 
 
 //-------------------------------------------------------------------------
-// RecResizeAdditional: Add more storage space
-//-------------------------------------------------------------------------
-#if 0
-void
-RecResizeAdditional(int add)
-{
-  // TODO: Hmmm, why couldn't I get xrealloc() to work here?
-  // TODO: This doesn't seem to work well at all ... *sigh*
-  void *tmp = xmalloc((g_max_records + add) * sizeof(RecRecord));
-
-  if (NULL != tmp) {
-    memset(tmp, 0, (g_max_records + add) * sizeof(RecRecord)); // Little unoptimal, ENOCARE
-    memcpy(tmp, g_records, g_max_records * sizeof(RecRecord));
-    g_records = (RecRecord *)tmp;
-    g_max_records += add;
-  } else {
-    ink_fatal(1, "can't reallocate for librecords API stats (adding %d records)", add);
-  }
-}
-#endif
-
-
-//-------------------------------------------------------------------------
 // RecSetDiags
 //-------------------------------------------------------------------------
 int

Modified: trafficserver/traffic/trunk/librecords/RecUtils.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/RecUtils.cc?rev=1002226&r1=1002225&r2=1002226&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/RecUtils.cc (original)
+++ trafficserver/traffic/trunk/librecords/RecUtils.cc Tue Sep 28 15:44:31 2010
@@ -35,8 +35,8 @@ extern Diags *g_diags;
 RecRecord*
 RecAlloc(RecT rec_type, const char *name, RecDataT data_type)
 {
-  if (g_num_records >= g_max_records) {
-    Warning("too many stats/configs, please increase REC_MAX_RECORDS or proxy.config.stat_api.max_stats_allowed");
+  if (g_num_records >= REC_MAX_RECORDS) {
+    Warning("too many stats/configs, please increase REC_MAX_RECORDS or rebuild with --with_max_api_stats=<n>");
     return NULL;
   }
 

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1002226&r1=1002225&r2=1002226&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Tue Sep 28 15:44:31 2010
@@ -1563,8 +1563,6 @@ api_init()
   static int init = 1;
 
   if (init) {
-    int api_stats_size = 0;
-
     init = 0;
 
 #ifndef UNSAFE_FORCE_MUTEX
@@ -1817,12 +1815,12 @@ api_init()
     cache_global_hooks = NEW(new CacheAPIHooks);
     global_config_cbs = NEW(new ConfigUpdateCbTable);
 
-    TS_ReadConfigInteger(api_stats_size, "proxy.config.stat_api.max_stats_allowed");
-    if (api_stats_size > 0) {
-      // RecResizeAdditional(api_stats_size);
-      api_rsb = RecAllocateRawStatBlock(api_stats_size);
+    if (TS_MAX_API_STATS > 0) {
+      api_rsb = RecAllocateRawStatBlock(TS_MAX_API_STATS);
       if (NULL == api_rsb) {
         Warning("Can't allocate API stats block");
+      } else {
+        Debug("sdk", "initialized SDK stats APIs with %d slots", TS_MAX_API_STATS);
       }
     } else {
       api_rsb = NULL;