bug in big pipe code causing performance problems

From: Pierre Beyssac (pb_at_fasterix.frmug.org)
Date: 07/30/03

  • Next message: Juli Mallett: "Re: make -U"
    Date: Wed, 30 Jul 2003 23:32:49 +0200
    To: freebsd-current@freebsd.org
    
    

    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
    _______________________________________________
    freebsd-current@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-current
    To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
    

  • Next message: Juli Mallett: "Re: make -U"

    Relevant Pages

    • A Helpful tip
      ... I have been rebuilding my chopped 66 bug. ... I stuck the tip into the end of the gas line and then ... Then I started snakeing it into the pipe. ... minutes I broke through the clog. ...
      (rec.autos.makers.vw.aircooled)
    • Re: how does one buy aftermarket pipes?
      ... capable of being splattered like a bug ... ... you either ride with people or you don't ride ... ... you with the pipe and other go fast shit ... and being argumentative has lost its charm here ...
      (rec.motorcycles)
    • Re: Help: redirecting process input/output
      ... serious, and very subtle, bug that can lead to deadlock. ... to 'read' from the pipe. ... Each process blocks in 'read' and then blocks in 'write'. ...
      (comp.os.linux.networking)
    • Re: pipe,fork,exec
      ... Here is obviously a bug. ... pipe takes an array of two integers ... as argument used to return the filedescriptors see ... read past the newline. ...
      (comp.os.linux.development.apps)
    • Re: Memory leak in 2.6.11-rc1?
      ... One new thing about the pipe code is that it ... if your memory freeing code depends on the fact that all HIGHMEM ... new pipe code introduces highmem pages that weren't highmem before. ... such long-lived and unfreeable pages have been there before too: kernel ...
      (Linux-Kernel)