From: hadaq Date: Tue, 8 Apr 2008 14:56:47 +0000 (+0000) Subject: dumping of the fill levels of buffers added. S.Y. X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=609904d6c038152a2c317dc75b0cf77b6e591da6;p=daqdata.git dumping of the fill levels of buffers added. S.Y. --- diff --git a/hadaq/netmem.c b/hadaq/netmem.c index f0a0a36..0646e83 100644 --- a/hadaq/netmem.c +++ b/hadaq/netmem.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.30 2008-03-31 17:48:20 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.31 2008-04-08 14:56:47 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L @@ -32,6 +32,7 @@ typedef struct TheArgsS { long varQSize[MAXINPATH]; int varQSizeCnt; char verbosity[PARAM_MAX_VALUE_LEN]; + unsigned int buffStat; } TheArgs; static jmp_buf terminateJmp; @@ -44,6 +45,7 @@ void sigHandler(int sig) static void usage(const char *progName) { syslog(LOG_ERR, "Usage: %s -i inPath [-i inPath] -m nrOfMsgs [-p priority]", progName); + syslog (LOG_ERR, "[-b 0|1] show fill levels of buffers]"); } static void argsDump(TheArgs *my) @@ -77,6 +79,7 @@ static void argsDefault(TheArgs *my) for (i = 0; i < MAXINPATH; i++) { my->varQSize[i] = 1 * 1024 * 1024; } + my->buffStat = 0; } static int argsFromCL(TheArgs *my, int argc, char *argv[]) @@ -89,7 +92,7 @@ static int argsFromCL(TheArgs *my, int argc, char *argv[]) inPathCntFromParam = my->inPathCnt; my->inPathCnt = 0; - while ((i = getopt(argc, argv, "ai:m:q:p:v:")) != -1) { + while ((i = getopt(argc, argv, "ai:m:q:p:v:b:")) != -1) { switch (i) { case 'm': my->nrOfMsgs = atoi(optarg); @@ -109,6 +112,9 @@ static int argsFromCL(TheArgs *my, int argc, char *argv[]) case 'v': strcpy(my->verbosity, optarg); break; + case 'b': + my->buffStat = strtoul (optarg, NULL, 0); + break; default: return -1; break; @@ -157,6 +163,138 @@ static char *unit(unsigned long v) return retVal; } +static void printTime() +{ + struct timeval tv; + struct tm* ptm; + char time_string[40]; + long milliseconds; + + gettimeofday( &tv, NULL ); + + /* Obtain the time of day, and convert it to a tm struct. */ + ptm = localtime (&tv.tv_sec); + + /* Format the date and time, down to a single second. */ + strftime (time_string, sizeof (time_string), "%Y-%m-%d %H:%M:%S", ptm); + + /* Compute milliseconds from microseconds. */ + milliseconds = tv.tv_usec / 1000; + + /* Print the formatted time, in seconds, followed by a decimal point + and the milliseconds. */ + printf ("Time: %s.%03ld\n", time_string, milliseconds); +} + +static void +statsBufferDump (TheArgs * theArgs, float interval, ShmTrans **shmtr, NetTrans **my) +{ + static time_t t0 = 0; + time_t t, dT; + int i, j; + int col = 0; + char emptybuffer[] = "-"; + int outputGraph = 1; /* Graphical output */ + int outputNum = 0; /* Numerical output */ + + t = time (NULL); + dT = t - t0; + + /* fprintf (stderr, " dT: %.0lf interval: %.0lf", (double)dT, interval); */ + + if (dT >= interval && theArgs->buffStat == 1) + { + + if( outputNum == 1) { + fputs("==============================================================================\n\n",stderr); + for(i=0; inrOfMsgs; i++) { + + fprintf (stderr, "q[%2d]: ", i); + if (shmtr[i] != NULL) + if (theArgs->varQSize[i]*2 - HadTuQueue_size(shmtr[i]->wrQueue) > 0) { + fprintf (stderr, "%8d ", HadTuQueue_size(shmtr[i]->wrQueue)); + } + else { + fprintf (stderr, "%8s ", "EXCEEDED"); + } + else + fprintf (stderr, "%8s ", emptybuffer); + + col++; + if (col == 6) { + fputc ('\n', stderr); + col = 0; + } + } + } + + if( outputGraph == 1 ){ + fputs ("------------------ buffer fill levels ----------------------------------------\n", stderr); + + float buffSize, queueSize, pktsDisc; + int maxnorm = 10.; + + for( j=0; jnrOfMsgs; i++ ){ + buffSize = 2*theArgs->varQSize[i]; + queueSize = HadTuQueue_size(shmtr[i]->wrQueue); + + if(maxnorm - maxnorm*queueSize/buffSize < j){ + fputc( '|', stderr ); + } + else{ + fputc( ' ', stderr ); + } + } + fputc( '\n', stderr ); + } + + /* The following is just to print the numbers of buffers*/ + int factor, mod; + + fputs( "q:", stderr ); + factor = 0; + for( i=0; inrOfMsgs; i++ ) { + mod = i%10; + fprintf (stderr, "%1d", mod); + } + fputc( '\n', stderr ); + + fputs( " ", stderr ); + for( i=0; inrOfMsgs; i++ ) { + mod = i%10; + if( mod == 0 ) + fprintf (stderr, "%1d", i/10 ); + else + fputc( ' ', stderr ); + } + fputc( '\n', stderr ); + + fputs( "------------------ discarded packets -----------------------------------------\n", stderr ); + for( j=0; jnrOfMsgs; i++ ){ + pktsDisc = (*my[i]->pktsDiscarded); + + if(maxnorm - (pktsDisc + maxnorm - 1)/maxnorm < j){ + fputc( 'D', stderr ); + } + else{ + fputc( ' ', stderr ); + } + } + fputc( '\n', stderr ); + } + + /* get wall-clock time */ + printTime(); + } + } + + t0 = t; +} + static void statsDump(TheArgs *theArgs, NetTrans **my, int interval) { static unsigned long lastBR[MAXINPATH]; @@ -165,7 +303,7 @@ static void statsDump(TheArgs *theArgs, NetTrans **my, int interval) int i; - if (theArgs->isStandalone && strcmp(theArgs->verbosity, "info") == 0 && (dT = (time(NULL) - lastTime)) >= interval) { + if (theArgs->isStandalone && strcmp(theArgs->verbosity, "info") == 0 && (dT = (time(NULL) - lastTime)) >= interval && theArgs->buffStat == 0) { fputs("==============================================================================\n", stderr); for (i = 0; i < theArgs->nrOfMsgs; i++) { fprintf(stderr, "%17s%02d:%6s", "pktsReceived", i, unit(*my[i]->pktsReceived)); @@ -317,6 +455,7 @@ int main(int argc, char *argv[]) long msgsCompleted; statsDump(theArgs, netTrans, 1); + statsBufferDump (theArgs, 1, shmTrans, netTrans); for (i = 0; i < theArgs->nrOfMsgs; i++) { if (hadTu[i] == NULL) {