Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Feb 1999 22:41:56 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        freebsd-current@FreeBSD.ORG
Subject:   Re: Weird piecemeal reads over socketpair() pipe breaks up small writes into even smaller reads.
Message-ID:  <199902150641.WAA12845@apollo.backplane.com>
References:   <199902150619.RAA24136@godzilla.zeta.org.au>

next in thread | previous in thread | raw e-mail | index | archive | help

:
:>    This isn't a 'bug', per say, but it bothers me that a small 128 byte
:>    write() is being somehow broken apart into two smaller read()s.  It isn't
:>    efficient, and it shouldn't be happening.
:
:Breaking apart write() into read()s would be a BUG :-).
:
:Breaking apart read() into read()s seems to be caused by my rescheduling
:changes in kern_subr.c.
:
:>    fcntl(fds[0], F_SETFL, O_NONBLOCK);
:
:Here you permit non-atomic reads for block sizes <= PIPE_BUF, so you should
:be prpared to get them.

    Well of course.  Why do you think I said "This isn't a 'bug', per say", 
    eh? 

:>    if (fork() == 0) {
:>        sleep(1);
:>        write(fds[1], buf, sizeof(buf));
:>        _exit(1);
:>    }
:
:The write() apparently begins by copyout()ing only 96 bytes, and if the
:need_resched() condition is true, then the process doing the write will
:block.
:
:>    select(fds[0] + 1, &rfds, NULL, NULL, NULL);
:>    while ((n = read(fds[0], buf, sizeof(buf))) > 0)
:>        printf("read %d\n", n);
:>    return(0);
:
:When the writer blocks, the reader runs and uses a buggy loop to read
:only the first chunk of input.
:
:Bruce

    Ok, so perhaps tweeking the rescheduling changes in kern_subr.c to
    not try to do it in the first few thousand bytes copied is the solution?
    Would you like to do it or should I?  This isn't high priority but it
    should definitely not be rescheduling after the first 96 bytes.  That's
    just a waste of cpu.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902150641.WAA12845>