Hi, I've attached a patch which gives iperf similar performance to netperf on my FreeBSD, MacOSX and Solaris hosts. It does not seem to negatively impact Linux. I only started looking at the iperf source yesterday, so I don't really expect this to be integrated as is, but a patch is worth a 1000 words :) Background: On both Solaris and FreeBSD, there are 2 things slowing iperf down: The gettimeofday timestamp around each socket read/write is terribly expensive, and the sched_yield() or usleep(0) causes iperf to take 100% of the time (system time on BSD, split user/system time on Solaris and MacOSX), which slows things down and confuses the scheduler. To address the gettimeofday() issue, I treat TCP different than UDP, and TCP tests behave as though only a single (huge) packet was sent. Rather then ending the test based on polling gettimeofday() timestamps, an interval timer / sigalarm handler is used. I had to increase the packetLen from an int to a max_size_t. To address the sched_yield/usleep issue, I put the reporter thread to sleep on a condition variable. For the TCP tests at least, there is no reason to have it running during the test and it is best to just get it out of the way rather than burning CPU in a tight loop. I've also incorporated some fixes from the FreeBSD ports collection: --- include/headers.h use a 64-bit type for max_size_t --- compat/Thread.c oldTID is not declared anywhere. Make this compile (seems needed for at least FreeBSD & MacOSX) --- src/Client.cpp BSDs can return ENOBUFS during a UDP test when the socket buffer fills. Don't exit when this happens. I've run the resulting iperf on FreeBSD, Solaris, MacOSX and Linux, and it seems to work for me. It is nice not to have a 100% CPU load when running an iperf test across a 100Mb/s network. Drew
Attachment:
non-linux.diff
Description: Binary data