bug in big pipe code causing performance problems

From: Pierre Beyssac <pb_at_fasterix.frmug.org>
Date: Wed, 30 Jul 2003 23:32:49 +0200
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
_at__at_ -1041,7 +1041,8 _at__at_
 		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	      	    pb_at_fasterix.frmug.org pb_at_fasterix.freenix.org
    Free domains: http://www.eu.org/ or mail dns-manager_at_EU.org
Received on Wed Jul 30 2003 - 12:32:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:17 UTC