Slashdot Mirror


Zero-Copy TCP and UDP Output in NetBSD

-is writes "Jason R. Thorpe has recently added experimental code to NetBSD-current, that enables zero-copy for TCP and UDP on the transmit-side. These changes could mean significant performance improvements for FTP, WWW, and Samba servers. See Jason's announcement to the current-users mailing list for details." From the text: " On tests on an embedded system with limited memory bandwith, TCP transmit performance on 100baseTX-FDX went from ~6500KB/s to ~11100KB/s, a significant improvement." Excellent!

2 of 74 comments (clear)

  1. Re:Packet loss by AdamBa · · Score: 5, Informative
    You know when the packet was received when you get an ack for it (for TCP, with UDP you can just dump it to the network card and forget about it since it's unreliable delivery). Obviously in this situation you need to hold on to the user's buffer until you have gotten an ack, otherwise you don't have the data until you need to retransmit. But you want to optimize for the general case which is you do get an ack real quick and then you can just return the buffer...I suppose a clever TCP implementation using this would have some spare buffers, and after some time without an ack (maybe the first retransmission, maybe sooner), it would copy the data and give the user's buffer back. But again that is a rare case so the extra copy there doesn't matter.

    As fow how noticeable they will be...according to the email, it increased from 52 megabits/second to almost 90 megabits/second. But transmitting over a series of hops (like on the Internet), your speed is gated by the slowest link or router, and it is doubtful the whole end-to-end chain will be able to handle 90 Mbps (or 52 Mbps for that matter). So even with a monster send window you would still need to stop transmitting well before you got an ack and could send more.

    Of course on a local 100 Mbps Ethernet playing networked games this could be quite nice.

    - adam

  2. FreeBSD has zerocopy sendfile... by lamontg · · Score: 5, Informative

    A basic bit of research by running 'man sendfile' on a FreeBSD system would have told you this:

    SENDFILE(2) FreeBSD System Calls Manual SENDFILE(2)

    NAME
    sendfile - send a file to a socket

    LIBRARY
    Standard C Library (libc, -lc)

    SYNOPSIS
    #include sys/types.h
    #include sys/socket.h
    #include sys/uio.h

    int
    sendfile(int fd, int s, off_t offset, size_t nbytes,
    struct sf_hdtr *hdtr, off_t *sbytes, int flags);

    DESCRIPTION
    Sendfile() sends a regular file specified by descriptor fd out a stream
    socket specified by descriptor s.

    [...]

    IMPLEMENTATION NOTES
    The FreeBSD implementation of sendfile() is "zero-copy", meaning that it
    has been optimized so that copying of the file data is avoided.