[sane-devel] increase your scanning by 22%

Daniel Drake dsd at gentoo.org
Fri Nov 21 17:17:05 UTC 2008


Hi,

Over the last few months, I have been developing the next major version 
of libusb: libusb-1.0

It is API-incompatible with libusb-0.1, which is used by SANE, but it is 
designed so that you can install both 0.1 and 1.0 on the same system 
without any problems.

I also developed an "emulation layer" which is effectively a replacement 
for libusb-0.1, called libusb-compat-0.1.
libusb-compat-0.1 implements exactly the same API as libusb-0.1, but it 
just converts the libusb-0.1 function calls into their 1.0 equivalents.

The advantage of using the emulation layer (over plain old libusb-0.1) 
is that you can then take advantage of some of the cool stuff in 
libusb-1.0. In some circumstances, transfers are a lot faster.

So, I tried libusb-compat-0.1 + libusb-1.0 with SANE, on my HP 
photosmart C4180 scanner. This is an old computer, so it only has USB 1.1.

Using libusb-0.1, scanning an A4 page took 73 seconds.
With my new libraries, it takes 60 seconds. That's 22% faster. I am 
using this command to scan:

time scanimage --format tiff --resolution 300 --compression None \
	> filename

I believe further speed increases are possible, if sane was to switch to 
libusb-1.0 and use the asynchronous transfer model to queue up multiple 
USB requests at once at the hardware level.  However, that requires code 
changes in sane and is probably some way down the line. The cool thing 
about what I've described above is that you don't have to change sane in 
any way.

It would be cool if other people could install libusb-1.0 and 
libusb-compat-0.1, test it, and measure the difference in speed.

Source downloads here:
https://sourceforge.net/project/showfiles.php?group_id=1674

Note that libusb-compat-0.1 (intentionally) conflicts with libusb-0.1, 
so don't try to have them both installed at once.

Daniel



More information about the sane-devel mailing list