Jan Wieck wrote: > Tom Lane wrote: > > Now this would put a pretty tight time constraint on the collector: > > fall more than 4K behind, you start losing data. I am not sure if > > a UDP socket would provide more buffering or not; anyone know? > > Looks like Linux has something around 16-32K of buffer space > for UDP sockets. Just from eyeballing the fprintf(3) output > of my destructively hacked postleprechaun. Just to get some evidence at hand - could some owners of different platforms compile and run the attached little C source please? (The program tests how much data can be stuffed into a pipe or a Sys-V message queue before the writer would block or get an EAGAIN error). My output on RedHat6.1 Linux 2.2.17 is: Pipe buffer is 4096 bytes Sys-V message queue buffer is 16384 bytes Seems Tom is (unfortunately) right. The pipe blocks at 4K. So a Sys-V message queue, with the ability to distribute messages from the collector to individual backends with kernel support via "mtype" is four times by unestimated complexity better here. What does your system say? I really never thought that Sys-V IPC is a good way to go at all. I hate it's incompatibility to the select(2) system call and all these OS/installation dependant restrictions. But I'm tempted to reevaluate it "for this case". Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== [EMAIL PROTECTED] #
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> typedef struct test_message { long mtype; char mtext[512 - sizeof(long)]; } test_message; static int test_pipe(void); static int test_msg(void); int main(int argc, char *argv[]) { if(test_pipe() < 0) return 1; if(test_msg() < 0) return 1; return 0; } static int test_pipe(void) { int p[2]; char buf[512]; int done; int rc; if (pipe(p) < 0) { perror("pipe(2)"); return -1; } if (fcntl(p[1], F_SETFL, O_NONBLOCK) < 0) { perror("fcntl(2)"); return -1; } for(done = 0; ; ) { if ((rc = write(p[1], buf, sizeof(buf))) != sizeof(buf)) { if (rc < 0) { extern int errno; if (errno == EAGAIN) { printf("Pipe buffer is %d bytes\n", done); return 0; } perror("write(2)"); return -1; } fprintf(stderr, "whatever happened - rc = %d on write(2)\n", rc); return -1; } done += rc; } fprintf(stderr, "Endless write loop returned - what's that?\n"); return -1; } static int test_msg(void) { int mq; test_message msg; int done; if ((mq = msgget(IPC_PRIVATE, IPC_CREAT | 0600)) < 0) { perror("msgget(2)"); return -1; } for (done = 0; ; ) { msg.mtype = 1; if (msgsnd(mq, &msg, sizeof(msg), IPC_NOWAIT) < 0) { extern int errno; if (errno == EAGAIN) { printf("Sys-V message queue buffer is %d bytes\n", done); return 0; } perror("msgsnd(2)"); return -1; } done += sizeof(msg); } fprintf(stderr, "Endless write loop returned - what's that?\n"); return -1; }
---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]