From owner-freebsd-current@FreeBSD.ORG Wed Jul 30 14:32:52 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CFBED37B401; Wed, 30 Jul 2003 14:32:52 -0700 (PDT) Received: from fasterix.frmug.org (fasterix.frmug.org [137.194.36.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9ABEA43FAF; Wed, 30 Jul 2003 14:32:51 -0700 (PDT) (envelope-from pb@fasterix.frmug.org) Received: from fasterix.frmug.org (localhost [127.0.0.1]) by fasterix.frmug.org (8.12.9/8.12.9) with ESMTP id h6ULWnXa001385 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 30 Jul 2003 23:32:50 +0200 (CEST) (envelope-from pb@fasterix.frmug.org) Received: (from pb@localhost) by fasterix.frmug.org (8.12.9/8.12.9/Submit) id h6ULWn0W001384; Wed, 30 Jul 2003 23:32:49 +0200 (CEST) Date: Wed, 30 Jul 2003 23:32:49 +0200 From: Pierre Beyssac To: freebsd-current@freebsd.org Message-ID: <20030730213249.GA900@fasterix.frmug.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-message-flag: Warning! Use of Microsoft Outlook is dangerous and makes your system susceptible to worms and viruses cc: silby@freebsd.org Subject: bug in big pipe code causing performance problems X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2003 21:32:53 -0000 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 pb@fasterix.frmug.org pb@fasterix.freenix.org Free domains: http://www.eu.org/ or mail dns-manager@EU.org