Hello,

If no one objects to it, I'd like to commit the following ASAP. It
fixes an obvious bug in the big pipe code, a discrepancy between
how free space is calculated in write vs poll. The bug affects
stable as well.

The bug's implications are less obvious: it make write(2) on a
non-blocking pipe return EAGAIN when poll(2) & select(2) return the
descriptor as ready for write. This in turns causes the libc_r code
to busy-wait on pipes, causing a major performance hog.

As an example the patch boosts the multimedia/transcode port (a big
pipes & threads user) by a factor of 2-3.

Index: sys_pipe.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/sys_pipe.c,v
retrieving revision 1.140
diff -u -r1.140 sys_pipe.c
--- sys_pipe.c  30 Jul 2003 18:55:04 -0000      1.140
+++ sys_pipe.c  30 Jul 2003 21:19:41 -0000
@@ -1041,7 +1041,8 @@
                if ((space < uio->uio_resid) && (orig_resid <= PIPE_BUF))
                        space = 0;
 
-               if (space > 0 && (wpipe->pipe_buffer.cnt < PIPE_SIZE)) {
+               if (space > 0
+                   && wpipe->pipe_buffer.cnt < wpipe->pipe_buffer.size) {
                        if ((error = pipelock(wpipe,1)) == 0) {
                                int size;       /* Transfer size */
                                int segsize;    /* first segment to transfer */
-- 
Pierre Beyssac              [EMAIL PROTECTED] [EMAIL PROTECTED]
    Free domains: http://www.eu.org/ or mail [EMAIL PROTECTED]
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to