[netperf-dev] netperf2 commit notice r69 - trunk/src
raj at netperf.org
raj at netperf.org
Fri Apr 14 16:17:15 PDT 2006
Author: raj
Date: 2006-04-14 16:17:13 -0700 (Fri, 14 Apr 2006)
New Revision: 69
Modified:
trunk/src/netlib.c
trunk/src/netlib.h
trunk/src/nettest_bsd.c
Log:
Cleanup the "#ifdef DIRTY" code considerably. Now call a single routine
to access the buffer and do so safely. Other nettest_mumble.c files may
still need to be converted. That will probably happen on an "as needed"
basis.
Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c 2006-04-14 22:25:02 UTC (rev 68)
+++ trunk/src/netlib.c 2006-04-14 23:17:13 UTC (rev 69)
@@ -1288,6 +1288,44 @@
return(first_link); /* it's a circle, doesn't matter which we return */
}
+/* this routine will dirty the first dirty_count bytes of the
+ specified buffer and/or read clean_count bytes from the buffer. it
+ will go N bytes at a time, the only question is how large should N
+ be and if we should be going continguously, or based on some
+ assumption of cache line size */
+
+void
+access_buffer(char *buffer_ptr,int length, int dirty_count, int clean_count) {
+
+ char *temp_buffer;
+ char *limit;
+ int i, dirty_totals;
+
+ temp_buffer = buffer_ptr;
+ limit = temp_buffer + length;
+
+ for (i = 0;
+ ((i < dirty_count) && (temp_buffer < limit));
+ i++) {
+ *temp_buffer += i;
+ dirty_totals += *temp_buffer;
+ temp_buffer++;
+ }
+
+ for (i = 0;
+ ((i < clean_count) && (temp_buffer < limit));
+ i++) {
+ dirty_totals += *temp_buffer;
+ temp_buffer++;
+ }
+
+ if (debug > 100) {
+ fprintf(where,
+ "This was here to try to avoid dead-code elimination %d\n",
+ dirty_totals);
+ fflush(where);
+ }
+}
#ifdef HAVE_ICSC_EXS
Modified: trunk/src/netlib.h
===================================================================
--- trunk/src/netlib.h 2006-04-14 22:25:02 UTC (rev 68)
+++ trunk/src/netlib.h 2006-04-14 23:17:13 UTC (rev 69)
@@ -497,6 +497,11 @@
extern void catcher(int);
#endif /* __hpux */
extern struct ring_elt *allocate_buffer_ring();
+extern void access_buffer(char *buffer_ptr,
+ int length,
+ int dirty_count,
+ int clean_count);
+
#ifdef HAVE_ICSC_EXS
extern struct ring_elt *allocate_exs_buffer_ring();
#endif /* HAVE_ICSC_EXS */
Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c 2006-04-14 22:25:02 UTC (rev 68)
+++ trunk/src/nettest_bsd.c 2006-04-14 23:17:13 UTC (rev 69)
@@ -207,7 +207,7 @@
#define INTERVALS_INIT() \
if (interval_burst) { \
/* zero means that we never pause, so we never should need the \
- /* interval timer. we used to use it for demo mode, but we deal \
+ interval timer. we used to use it for demo mode, but we deal \
with that with a variant on watching the clock rather than \
waiting for a timer. raj 2006-02-06 */ \
start_itimer(interval_wate); \
@@ -1194,11 +1194,6 @@
/* the size of the local senc socket buffer. We will want to deal */
/* with alignment and offset concerns as well. */
-#ifdef DIRTY
- int *message_int_ptr;
- int i,dirty_totals;
-#endif
-
struct ring_elt *send_ring;
int len;
@@ -1467,12 +1462,6 @@
INTERVALS_INIT();
#endif /* WANT_INTERVALS */
-#ifdef DIRTY
- /* initialize the random number generator for putting dirty stuff */
- /* into the send buffer. raj */
- srand((int) getpid());
-#endif
-
/* before we start, initialize a few variables */
#ifdef WANT_DEMO
@@ -1491,41 +1480,10 @@
while ((!times_up) || (bytes_remaining > 0)) {
#ifdef DIRTY
- /* we want to dirty some number of consecutive integers in the
- buffer we are about to send. we may also want to bring some
- number of them cleanly into the cache. The clean ones will
- follow any dirty ones into the cache. at some point, we might
- want to replace the rand() call with something from a table to
- reduce our call overhead during the test, but it is not a high
- priority item.
-
- we should probably make sure that we don't go charging past the
- end of the buffer, nor changing the counts when running with
- confidence intervals. also, we probably neeed to do something
- to make sure that a compiler's dead code elimination doesn't
- take this stuff out. raj 2006-04-14 */
- message_int_ptr = (int *)(send_ring->buffer_ptr);
- for (i = 0;
- ((i < loc_dirty_count) &&
- (message_int_ptr < (send_ring->buffer_ptr + send_size)));
- i++) {
- *message_int_ptr = rand();
- dirty_totals += *message_int_ptr;
- message_int_ptr++;
- }
- for (i = 0;
- ((i < loc_clean_count) &&
- (message_int_ptr < (send_ring->buffer_ptr + send_size)));
- i++) {
- dirty_totals += *message_int_ptr;
- message_int_ptr++;
- }
- if (debug > 100) {
- fprintf(where,
- "This was here to try to avoid dead-code elimination %d\n",
- dirty_totals);
- fflush(where);
- }
+ access_buffer(send_ring->buffer_ptr,
+ send_size,
+ loc_dirty_count,
+ loc_clean_count);
#endif /* DIRTY */
#ifdef WANT_HISTOGRAM
@@ -1909,10 +1867,6 @@
/* the size of the local senc socket buffer. We will want to deal */
/* with alignment and offset concerns as well. */
-#ifdef DIRTY
- int *message_int_ptr;
-#endif
-
struct ring_elt *recv_ring;
int len;
@@ -1926,10 +1880,6 @@
/* 64bit integral type, but those are not entirely common yet */
double bytes_sent = 0.0;
-#ifdef DIRTY
- int i;
-#endif /* DIRTY */
-
float local_cpu_utilization;
float local_service_demand;
float remote_cpu_utilization;
@@ -2181,12 +2131,6 @@
INTERVALS_INIT();
#endif /* WANT_INTERVALS */
-#ifdef DIRTY
- /* initialize the random number generator for putting dirty stuff */
- /* into the recv buffer. raj */
- srand((int) getpid());
-#endif
-
/* before we start, initialize a few variables */
#ifdef WANT_DEMO
@@ -2201,21 +2145,10 @@
2002-06-21 */
#ifdef DIRTY
- /* we want to dirty some number of consecutive integers in the buffer */
- /* we are about to recv. we may also want to bring some number of */
- /* them cleanly into the cache. The clean ones will follow any dirty */
- /* ones into the cache. at some point, we might want to replace */
- /* the rand() call with something from a table to reduce our call */
- /* overhead during the test, but it is not a high priority item. */
- message_int_ptr = (int *)(recv_ring->buffer_ptr);
- for (i = 0; i < loc_dirty_count; i++) {
- *message_int_ptr = rand();
- message_int_ptr++;
- }
- for (i = 0; i < loc_clean_count; i++) {
- loc_dirty_count = *message_int_ptr;
- message_int_ptr++;
- }
+ access_buffer(recv_ring->buffer_ptr,
+ recv_size,
+ loc_dirty_count,
+ loc_clean_count);
#endif /* DIRTY */
#ifdef WANT_HISTOGRAM
@@ -2604,11 +2537,6 @@
/* the size of the local senc socket buffer. We will want to deal */
/* with alignment and offset concerns as well. */
-#ifdef DIRTY
- int *message_int_ptr;
- int i;
-#endif
-
struct ring_elt *send_ring;
int len;
@@ -2900,12 +2828,6 @@
INTERVALS_INIT();
#endif /* WANT_INTERVALS */
-#ifdef DIRTY
- /* initialize the random number generator for putting dirty stuff */
- /* into the send buffer. raj */
- srand((int) getpid());
-#endif
-
/* before we start, initialize a few variables */
#if 0 /* def WANT_DEMO */
@@ -2928,21 +2850,10 @@
while ((!times_up) || (bytes_remaining > 0)) {
#ifdef DIRTY
- /* we want to dirty some number of consecutive integers in the buffer */
- /* we are about to send. we may also want to bring some number of */
- /* them cleanly into the cache. The clean ones will follow any dirty */
- /* ones into the cache. at some point, we might want to replace */
- /* the rand() call with something from a table to reduce our call */
- /* overhead during the test, but it is not a high priority item. */
- message_int_ptr = (int *)(send_ring->buffer_ptr);
- for (i = 0; i < loc_dirty_count; i++) {
- *message_int_ptr = rand();
- message_int_ptr++;
- }
- for (i = 0; i < loc_clean_count; i++) {
- loc_dirty_count = *message_int_ptr;
- message_int_ptr++;
- }
+ access_buffer(send_ring->buffer_ptr,
+ send_size,
+ loc_dirty_count,
+ loc_clean_count);
#endif /* DIRTY */
#if 0 /* def WANT_HISTOGRAM */
@@ -3390,10 +3301,6 @@
/* the size of the local senc socket buffer. We will want to deal */
/* with alignment and offset concerns as well. */
-#ifdef DIRTY
- int *message_int_ptr;
-#endif
-
struct sendfile_ring_elt *send_ring;
int len;
@@ -3407,10 +3314,6 @@
/* 64bit integral type, but those are not entirely common yet */
double bytes_sent = 0.0;
-#ifdef DIRTY
- int i;
-#endif /* DIRTY */
-
float local_cpu_utilization;
float local_service_demand;
float remote_cpu_utilization;
@@ -3718,11 +3621,6 @@
INTERVALS_INIT();
#endif /* WANT_INTERVALS */
-#ifdef DIRTY
- /* initialize the random number generator for putting dirty stuff */
- /* into the send buffer. raj */
- /* srand((int) getpid()); */
-#endif
/* before we start, initialize a few variables */
@@ -4149,13 +4047,6 @@
char local_name[BUFSIZ];
char port_buffer[PORTBUFSIZE];
-#ifdef DIRTY
- int *message_int_ptr;
- int dirty_count;
- int clean_count;
- int i;
-#endif
-
#ifdef DO_SELECT
fd_set readfds;
struct timeval timeout;
@@ -4379,17 +4270,11 @@
/* them cleanly into the cache. The clean ones will follow any dirty */
/* ones into the cache. */
- dirty_count = tcp_stream_request->dirty_count;
- clean_count = tcp_stream_request->clean_count;
- message_int_ptr = (int *)recv_ring->buffer_ptr;
- for (i = 0; i < dirty_count; i++) {
- *message_int_ptr = rand();
- message_int_ptr++;
- }
- for (i = 0; i < clean_count; i++) {
- dirty_count = *message_int_ptr;
- message_int_ptr++;
- }
+ access_buffer(recv_ring->buffer_ptr,
+ recv_size,
+ tcp_stream_request->dirty_count,
+ tcp_stream_request->clean_count);
+
#endif /* DIRTY */
bytes_received = 0;
@@ -4413,15 +4298,10 @@
#endif /* PAUSE */
#ifdef DIRTY
- message_int_ptr = (int *)(recv_ring->buffer_ptr);
- for (i = 0; i < dirty_count; i++) {
- *message_int_ptr = rand();
- message_int_ptr++;
- }
- for (i = 0; i < clean_count; i++) {
- dirty_count = *message_int_ptr;
- message_int_ptr++;
- }
+ access_buffer(recv_ring->buffer_ptr,
+ recv_size,
+ tcp_stream_request->dirty_count,
+ tcp_stream_request->clean_count);
#endif /* DIRTY */
#ifdef DO_SELECT
@@ -4508,13 +4388,6 @@
struct ring_elt *send_ring;
-#ifdef DIRTY
- int *message_int_ptr;
- int dirty_count;
- int clean_count;
- int i;
-#endif
-
struct tcp_maerts_request_struct *tcp_maerts_request;
struct tcp_maerts_response_struct *tcp_maerts_response;
struct tcp_maerts_results_struct *tcp_maerts_results;
@@ -4737,25 +4610,6 @@
/* The loop will exit when the sender does a shutdown, which will */
/* return a length of zero */
-#ifdef DIRTY
- /* we want to dirty some number of consecutive integers in the buffer */
- /* we are about to send. we may also want to bring some number of */
- /* them cleanly into the cache. The clean ones will follow any dirty */
- /* ones into the cache. */
-
- dirty_count = tcp_maerts_request->dirty_count;
- clean_count = tcp_maerts_request->clean_count;
- message_int_ptr = (int *)send_ring->buffer_ptr;
- for (i = 0; i < dirty_count; i++) {
- *message_int_ptr = rand();
- message_int_ptr++;
- }
- for (i = 0; i < clean_count; i++) {
- dirty_count = *message_int_ptr;
- message_int_ptr++;
- }
-#endif /* DIRTY */
-
bytes_sent = 0.0;
send_calls = 0;
@@ -4765,15 +4619,16 @@
while (!times_up) {
#ifdef DIRTY
- message_int_ptr = (int *)(send_ring->buffer_ptr);
- for (i = 0; i < dirty_count; i++) {
- *message_int_ptr = rand();
- message_int_ptr++;
- }
- for (i = 0; i < clean_count; i++) {
- dirty_count = *message_int_ptr;
- message_int_ptr++;
- }
+ /* we want to dirty some number of consecutive integers in the buffer */
+ /* we are about to send. we may also want to bring some number of */
+ /* them cleanly into the cache. The clean ones will follow any dirty */
+ /* ones into the cache. */
+
+ access_buffer(send_ring->buffer_ptr,
+ send_size,
+ tcp_maerts_request->dirty_count,
+ tcp_maerts_request->clean_count);
+
#endif /* DIRTY */
if((len=send(s_data,
@@ -5632,11 +5487,6 @@
unsigned int sum_failed_sends;
double sum_local_thruput;
-#ifdef DIRTY
- int *message_int_ptr;
- int i;
-#endif /* DIRTY */
-
struct addrinfo *local_res;
struct addrinfo *remote_res;
@@ -5835,15 +5685,11 @@
/* we are about to send. we may also want to bring some number of */
/* them cleanly into the cache. The clean ones will follow any dirty */
/* ones into the cache. */
- message_int_ptr = (int *)(send_ring->buffer_ptr);
- for (i = 0; i < loc_dirty_count; i++) {
- *message_int_ptr = 4;
- message_int_ptr++;
- }
- for (i = 0; i < loc_clean_count; i++) {
- loc_dirty_count = *message_int_ptr;
- message_int_ptr++;
- }
+
+ access_buffer(send_ring->buffer_ptr,
+ send_size,
+ loc_dirty_count,
+ loc_clean_count);
#endif /* DIRTY */
#ifdef WANT_HISTOGRAM
More information about the netperf-dev
mailing list