[Spread-users] RE: Maximum message rate achieved is only 6600 msgs/sec (for message size 1300 bytes)

Sandesh sksodhi at gmail.com
Thu Nov 8 06:03:06 EST 2007


Hi John

Thanks for the quick response.

I am using spread_name of form "<port>".

As per you suggestion I tried to measure the performance of pipe on my system.
My system is supporting around 76000 msgs/sec (Each message 1300 bytes).


For your reference I am pasting the code that i used to measure the
performance of pipe
(changed example code provided by you in the last mail) -

#include <sys/wait.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#define DEBUG
#define DATA_SIZE 1300

#define FIRST_SEND_MSG_COUNT 10

#define SIGNATURE 123
int g_this_count = 1000000;
struct timeval tv1,tv2;




int
main(int argc, char *argv[])
{
   int pfd[2];
   int cfd[2];
   pid_t cpid;
   char sendbuf[DATA_SIZE];
   char recvbuf[sizeof(sendbuf)];
   int count =0;
   int ret;
   int diff_sec = 0;

   //assert(argc == 2);

   if (pipe(pfd) == -1) { perror("p1"); exit(EXIT_FAILURE); }
   if (pipe(cfd) == -1) { perror("p2"); exit(EXIT_FAILURE); }

   cpid = fork();
   if (cpid == -1) { perror("fork"); exit(EXIT_FAILURE); }

   /* Child reads from pfd[0] and writes to cfd[1] */
   /* Parent reads from cfd[0] and writes to pfd[1] */

   if (cpid == 0) {    /* child */
       close(pfd[1]);  /* Close parent's write end */
       close(cfd[0]);  /* Close parent's read end */


       printf("In child\n");
       sendbuf[DATA_SIZE-1] = SIGNATURE;
       recvbuf[DATA_SIZE-1] = 0;

       /* send + recv here */
       printf("Starting Iinitial write");
       while(1) {
#ifdef DEBUG
                   printf("Initial write count %d\n",count );
                   fflush(stdout);
#endif
                   if (count >= FIRST_SEND_MSG_COUNT) {
                           break;
                   }
                   count++;
                   ret = write(cfd[1],sendbuf, DATA_SIZE);
                   if (ret < 0) {
                           perror("Child: Initial write err");
                   }
       }


#ifdef DEBUG
       printf("Iinitial write over");
       fflush(stdout);
#endif
       count = 0;

       while(1) {
                   ret = write(cfd[1],sendbuf, DATA_SIZE);
                   if (ret < 0) {
                           perror("Child: send err");
                   }

                   ret = read(pfd[0],recvbuf, DATA_SIZE);
                   if (ret < 0) {
                           perror("Child: read err");
                   } else if (ret != DATA_SIZE) {
                           perror("Child: Didn't recv DATA_SIZE");
                   } else {
                       if (recvbuf[DATA_SIZE-1] != SIGNATURE) {
                           printf("Data is not what was sent\n");
                           fflush(stdout);
                           recvbuf[DATA_SIZE-1] = 0;
                           continue;
                       }
                       if (count % g_this_count == 0) {
                               gettimeofday(&tv1, NULL);

                               diff_sec = tv1.tv_sec - tv2.tv_sec;
                               // Ignoring usec difference. To get
proper message rate
                               // g_this_count can be increased.
                               //diff_usec = tv2.tv_sec - tv1.tv_sec;

                               if (diff_sec) {
                               printf("Read message count: %7d at sec
%11u usec %7u. msgs/sec: %6d \n",
                                               count, tv1.tv_sec,
tv1.tv_usec, g_this_count/diff_sec);
                               } else {
                                   printf("WARNNNNNNNING: You need to
increase g_this_count\n");
                               }
                               tv2.tv_sec  = tv1.tv_sec;
                               tv2.tv_usec = tv1.tv_usec;
                       }
                       count ++;
                   }
       }
           printf("5Iinitial write");

       close(pfd[0]);
       _exit(EXIT_SUCCESS);

   } else {            /* Parent */
       close(cfd[1]);  /* Close child's write end */
       close(pfd[0]);  /* Close child's read end */

       printf("In Parent \n");

       /* recv + send here */
       while(1) {
                   ret = read(cfd[0],recvbuf, DATA_SIZE);
                   if (ret < 0) {
                           perror("PARENT: recv err");
                   } else if (ret != DATA_SIZE) {
                           perror("PARENT: Didn't recv DATA_SIZE");
                   } else {
                           ret = write(pfd[1],recvbuf, DATA_SIZE);
                           if (ret < 0) {
                                   perror("PARENT: send err");
                           }
                   }

       }


       close(pfd[1]);          /* Reader will see EOF */
       wait(NULL);             /* Wait for child */
       exit(EXIT_SUCCESS);
   }
}


OUTOUT OF THE ABOVE PROGRAM
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
root at neptune ~ $./a.out
In Parent
In child
Starting Iinitial writeInitial write count 0
Initial write count 1
Initial write count 2
Initial write count 3
Initial write count 4
Initial write count 5
Initial write count 6
Initial write count 7
Initial write count 8
Initial write count 9
Initial write count 10
Iinitial write overRead message count:       0 at sec  1194546697 usec
 757626. msgs/sec:      0
Read message count: 1000000 at sec  1194546711 usec  238690. msgs/sec:  71428
Read message count: 2000000 at sec  1194546724 usec  413092. msgs/sec:  76923
Read message count: 3000000 at sec  1194546737 usec  757648. msgs/sec:  76923
Read message count: 4000000 at sec  1194546751 usec  212858. msgs/sec:  71428
Read message count: 5000000 at sec  1194546764 usec  379540. msgs/sec:  76923
Read message count: 6000000 at sec  1194546777 usec  840922. msgs/sec:  76923
Read message count: 7000000 at sec  1194546791 usec  446507. msgs/sec:  71428
Read message count: 8000000 at sec  1194546804 usec  850345. msgs/sec:  76923
Read message count: 9000000 at sec  1194546818 usec  327549. msgs/sec:  71428
Read message count: 10000000 at sec  1194546831 usec  748859. msgs/sec:  76923
Read message count: 11000000 at sec  1194546845 usec  465896. msgs/sec:  71428
^C


CPU UTILIZATION BY THE TWO PROCESS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Each of the two processes are using 45% CPU.


Thanks and Regards,
Sandesh Kumar Sodhi




More information about the Spread-users mailing list