Re: [PATCH] performance fixes for non-linux


Hello all!

I've finally found a bit of time to work on Iperf. I have applied Andrew's patch to the SVN tree on SourceForge.

I did rework it a little bit as it removed the interval reporting for TCP tests. So for now the compromise I made was that if -i is specified the stats update code (including the gettimeofday) will be called for each packet so that the stats can be reported. If -i is 0.0 (the default) then it will only be called once at the end of the transfer.

Eventually I'd like to go in and rework and possibly simplify the stats code. Hopefully there is a way to be able to use -i and not call gettimeofday. I am open to suggestions.

I am planning to release Iperf 2.0.3 later tonight if all goes well.

Many thanks to everyone who commented on how to improve the threading performance and especially to Andrew for coming up with a patch that works well on platforms other than Linux.

Cheers,

Jon

Andrew Gallatin wrote:
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



Other Mailing lists | Author Index | Date Index | Subject Index | Thread Index