[netperf-dev] netperf2 commit notice r376 - in trunk: . src

raj at netperf.org raj at netperf.org
Tue Jan 11 16:02:18 PST 2011


Author: raj
Date: 2011-01-11 16:02:18 -0800 (Tue, 11 Jan 2011)
New Revision: 376

Modified:
   trunk/Release_Notes
   trunk/src/hist.h
   trunk/src/netlib.c
   trunk/src/nettest_omni.c
Log:
make histogram and burst compatible

Modified: trunk/Release_Notes
===================================================================
--- trunk/Release_Notes	2011-01-11 21:27:46 UTC (rev 375)
+++ trunk/Release_Notes	2011-01-12 00:02:18 UTC (rev 376)
@@ -1,5 +1,11 @@
 These are the Release Notes for post-revision 2.4.5 of netperf:
 
+*) The histogram code has been enhanced to track more than one latency
+   at a time and so --enable-histogram and --enable-burst are now
+   compatible - for the omni tests or migrated "classic" tests only
+   however.  This change was inspired/instigated by Jim Gettys and his
+   work on overly-large queues of buffers
+
 *) WANT_MIGRATION is enabled when one specifies --enable-omni on the
    configure command line.
 

Modified: trunk/src/hist.h
===================================================================
--- trunk/src/hist.h	2011-01-11 21:27:46 UTC (rev 375)
+++ trunk/src/hist.h	2011-01-12 00:02:18 UTC (rev 376)
@@ -62,6 +62,24 @@
   double sumsquare;
   int hmin;
   int hmax;
+  int limit;
+  int count;
+  int producer;
+  int consumer;
+#ifdef HAVE_GETHRTIME
+  hrtime_t *time_ones;
+  hrtime_t time_two;
+#elif HAVE_GET_HRT
+  hrt_t *time_ones;
+  hrt_t time_two;
+#elif defined(WIN32)
+  LARGE_INTEGER *time_ones;
+  LARGE_INTEGER time_two;
+#else
+  struct timeval *time_ones;
+  struct timeval time_two;
+#endif /* HAVE_GETHRTIME */
+
 };
 
 typedef struct histogram_struct *HIST;
@@ -73,9 +91,17 @@
 HIST HIST_new(void); 
 
 /* 
+   HIST_new_n - return a new, cleard histogram data type able to track
+   at least max_outstanding timestamps
+*/
+
+HIST HIST_new_n(int max_outstanding);
+
+/* 
    HIST_clear - reset a histogram by clearing all totals to zero
 */
 
+
 void HIST_clear(HIST h);
 
 /*
@@ -107,6 +133,19 @@
 #endif
 
 /*
+  HIST_timestamp_start - start a new timestamp
+*/
+
+void HIST_timestamp_start(HIST h);
+
+/* 
+  HIST_timestamp_stop_add - complete the oldest outstanding timestamp
+  and add it to the histogram
+*/
+
+void HIST_timestamp_stop_add(HIST h);
+
+/*
   delta_micro - calculate the difference in microseconds between two
   timestamps
 */

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2011-01-11 21:27:46 UTC (rev 375)
+++ trunk/src/netlib.c	2011-01-12 00:02:18 UTC (rev 376)
@@ -3786,17 +3786,49 @@
 
 /*#define HIST_TEST*/
 
+HIST
+HIST_new_n(int max_outstanding) {
+  HIST h;
+  int bytes;
+  void *buf;
+  if((h = (HIST) malloc(sizeof(struct histogram_struct))) == NULL) {
+    perror("HIST_new_n - histogram_struct malloc failed");
+    exit(1);
+  }
+  HIST_clear(h);
+  /* now allocate the time_ones based on max_outstanding */
+  if (max_outstanding > 0) {
+#ifdef HAVE_GETHRTIME
+    h->time_ones = (hrtime_t *) malloc(max_outstanding * sizeof(hrtime_t));
+#elif HAVE_GET_HRT
+    h->time_ones = (hrt_t *) malloc(max_outstanding * sizeof(hrt_t));
+#elif defined(WIN32)
+    h->time_ones = (LARGE_INTEGER *) malloc(max_outstanding * 
+					    sizeof(LARGE_INTEGER));
+#else
+    h->time_ones = (struct timeval *) malloc(max_outstanding * 
+					     sizeof(struct timeval));
+#endif /* HAVE_GETHRTIME */
+    if (h->time_ones == NULL) {
+      perror("HIST_new_n - time_ones malloc failed");
+      exit(1);
+    }
+  }
+  else {
+    h->time_ones = NULL;
+  }
+  /* we never want to have a full queue, so will trade a little space
+     for that. one day we may still have to check for a full queue */
+  h->limit = max_outstanding + 1; 
+  return h;
+}
+  
 HIST 
 HIST_new(void){
-   HIST h;
-   if((h = (HIST) malloc(sizeof(struct histogram_struct))) == NULL) {
-     perror("HIST_new - malloc failed");
-     exit(1);
-   }
-   HIST_clear(h);
-   return h;
+  return HIST_new_n(0);
 }
 
+
 void 
 HIST_clear(HIST h){
    int i;
@@ -3815,7 +3847,12 @@
    h->sum = 0;
    h->sumsquare = 0;
    h->hmin = 0;
-   h->hmax =0;
+   h->hmax = 0;
+   h->limit = 0;
+   h->count = 0;
+   h->producer = 0;
+   h->consumer = 0;
+   h->time_ones = NULL;
 }
 
 void 
@@ -4099,6 +4136,73 @@
 }
 #endif /* HAVE_GETHRTIME */
 
+void
+HIST_timestamp_start(HIST h) {
+
+  if (NULL == h) {
+    fprintf(where,"HIST_timestamp_start called with NULL histogram\n");
+    fflush(where);
+    exit(-1);
+  }
+  if (h->count == h->limit) {
+    fprintf(where,"HIST_timestamp_start called with full time_ones\n");
+  }
+  if (debug) {
+    fprintf(where,
+	    "producing a timestamp at offset %d with consumer %d count %d limit %d\n",
+	    h->producer,
+	    h->consumer,
+	    h->count,
+	    h->limit);
+    fflush(where);
+  }
+
+  HIST_timestamp(&(h->time_ones[h->producer]));
+  h->producer += 1;
+  h->producer %= h->limit;
+  h->count += 1;
+
+
+}
+
+/* snap an ending timestamp and add the delta to the histogram */
+void
+HIST_timestamp_stop_add(HIST h) {
+
+  if (NULL == h) {
+    fprintf(where,"HIST_timestamp_stop called with NULL histogram\n");
+    fflush(where);
+    exit(-1);
+  }
+
+  if (h->consumer == h->producer) {
+    fprintf(where,
+	    "HIST_timestamp_stop called with empty time_ones consumer %d producer %d\n",
+	    h->consumer,
+	    h->producer);
+    fflush(where);
+    exit(-1);
+  }
+  /* take our stopping timestamp */
+  HIST_timestamp(&(h->time_two));
+
+  if (debug) {
+    fprintf(where,
+	    "consuming timstamp at offset %d with producer %d count %d\n",
+	    h->consumer,
+	    h->producer,
+	    h->count);
+    fflush(where);
+  }
+
+  /* now add it */
+  HIST_add(h,delta_micro(&(h->time_ones[h->consumer]),&(h->time_two)));
+  h->consumer += 1;
+  h->consumer %= h->limit;
+  h->count -= 1;
+
+}
+
 
 #ifdef WANT_DLPI
 

Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c	2011-01-11 21:27:46 UTC (rev 375)
+++ trunk/src/nettest_omni.c	2011-01-12 00:02:18 UTC (rev 376)
@@ -4342,7 +4342,10 @@
   }
   
   if (keep_histogram) {
-    time_hist = HIST_new();
+    if (first_burst_size > 0)
+      time_hist = HIST_new_n(first_burst_size + 1);
+    else
+      time_hist = HIST_new_n(1);
   }
 
   /* since we are now disconnected from the code that established the
@@ -4757,7 +4760,7 @@
 	 should not be a big deal.  famous last words of raj
 	 2008-01-08 */
       if (keep_histogram) {
-	HIST_timestamp(&time_one);
+	HIST_timestamp_start(time_hist);
       }
 
     again:
@@ -5049,8 +5052,7 @@
 
 
       if (keep_histogram) {
-	HIST_timestamp(&time_two);
-	HIST_add(time_hist,delta_micro(&time_one,&time_two));
+	HIST_timestamp_stop_add(time_hist);
       }
     
 #ifdef WANT_DEMO
@@ -7796,18 +7798,7 @@
 
 #if defined(WANT_HISTOGRAM)
   if (verbosity > 1) keep_histogram = 1;
-#if defined(WANT_FIRST_BURST) 
-  /* if WANT_FIRST_BURST and WANT_HISTOGRAM are defined and the user
-     indeed wants a non-zero first burst size, and we would emit a
-     histogram, then we should emit a warning that the two are not
-     compatible. raj 2006-01-31 */
-  if ((first_burst_size > 0) && (verbosity > 1)) {
-    fprintf(stderr,
-	    "WARNING! Histograms and first bursts are incompatible!\n");
-    fflush(stderr);
-  }
 #endif
-#endif
 
   /* ok, time to sanity check the output units */
   if ('?' == libfmt) {



More information about the netperf-dev mailing list