libusb performance on 8.1
Hans Petter Selasky
hselasky at c2i.net
Sat Jan 22 13:33:20 UTC 2011
On Thursday 20 January 2011 07:37:32 Daniel O'Connor wrote:
> [re-sent from the correct address]
> I am building a USB interface to a radar data acquisition chassis based on
> the Cypress CY7C68013A.
> While doing some speed testing I find that FreeBSD does ~4Mb/sec, but Linux
> does 17Mb/sec & OS X does 8-10Mb/sec.
You need to change the way you buffer the data. FreeBSD does not queue more
than 2 URB's at any time, and the turnaround time varies from 1ms to 125us due
to hardware IRQ restrictions. Linux queues up all it can get, which leads to
other kind of problems. The current internal buffer limit is 16Kbyte 8000
times per second which gives a MAX of 128 MByte/second.
In general during hardware design:
1) Avoid short packets.
2) Make sure transfer buffers are matched between host and device.
From my experience it is very possible to reach +30Mbyte/second with LibUSB
under FreeBSD 8.2+, given the buffering is optimal for the kernel.
Hint: The libusb20 API has features to transfer multi-short packets in a more
optimised way, which are not exposed in the libusb10 API.
> It is using libusb-1.0 with the async API in a threaded app. I spawn a
> thread which sites in the following loop:
More information about the freebsd-usb