Influence of buffer size and command queueing on the scan speed of the Sharp JX-250 with Sane and Linux

The JX-250 is, compared to many other cheaper scanners, relatively fast – an A4 size 400 dpi gray scale scans need only approximately 10 seconds – [1], but it has obviously a very small internal buffer. This means that, after the data transfer of a "read scan data" command has been finished, the next "read scan data" command must be issued as fast as possible to avoid scan head stops.

In order to get an idea about the importance of efficient command queueing and buffer size for the scan speed of the JX-250 with Sane und Linux, I made a number of tests with different configurations.

I used the following hardware:

For Scans without command queueing and with command queueing on the level of the Sane SCSI library, I used the Linux kernel version 2.2.7 with the SG driver 2.1.34; for command queueing on the level of the SG driver, I used the Linux kernel version 2.2.14 with the SG driver 2.1.36. All tests were made with a current (February 2000) Sane CVS version, which supports the queueing capabilities of the newer Linux SG drivers.

I made 4 scans for the following setups:

The following command was used for the scans: time scanimage -d sharp:/dev/scanner -l 0 -t 0 -x 216 -y 297 --mode Gray --resolution RES > /dev/null (RES as listed in the tables below)

In order to get additional activity on the SCSI bus, I ran a dd if=/dev/sda of=/dev/null bs=512 in parallel to some of the scans. This constant usage of the SCSI bus is of course not very realistic -- but it should give at least some idea about the influence of other devices connected to the SCSI bus on the scan speed.

Despite the daemons installed on an ordinary Suse Linux 6.1, no other programs were running during the tests.

Results

Celeron 433 / Adaptec 2940
resolution queue buffer size "dd if=/dev/sda .."
running
scan time (sec) scan head stops
200off32kno6.2..8.3no
200off32kyes6.3..8.4no
300off32kno7.8..8.4no
300off32kyes19.7..22.4yes
300off64kyes8.0..8.4no
400off32kno28.6..29.8yes
400off64kno20.4..21.8yes
400off128kno16.4..17.7yes
400off256kno12.4..12.6yes
300old32kyes18.4..19.9yes
300old64kyes8.2..9.8no
400old32kno28.5..28.6yes
400old64kno20.4..20.5yes
400old128kno12.3..13.7yes
400old256kno9.6..9.8no
400old256kyes15.2..15.5yes
400old512kyes9.8..11.3no
300new32kno7.8..8.0no
300new32kyes19.7..19.8yes
300new64kyes7.9..8.0no
400new32kno27.1..27.2yes
400new64kno16.3..16.4yes
400new128kno9.6..9.7no
400new128kyes28.7..30.0yes
400new256kyes15.2..15.3yes
400new512kyes9.8..9.9no

Pentium 100 MHz / Adaptec 2940
resolution queue buffer size "dd /dev/sda .."
running
scan time (sec) scan head stops
200off32kno7.7..8.4no
200off32kyes7.8..8.7no
300off32kno7.9..8.7for some scans
300off32kyes20.0..20.1yes
300off64kyes8.4..8.5no
400off32kno37.9..38.1yes
400off64kno31.2..31.4yes
400off128kno29.8..29.9yes
400off256kno25.8..25.9yes
300old32kno19.8..20.1yes
300old64kno8.2..8.6no
300old64kyes8.1..8.5no
400old32kno31.7..32.6yes
400old64kno25.8..25.9yes
400old128kno20.5..21.9yes
400old256kno16.4..16.5yes
400old512kno15.1..15.2yes
300new32kno8.1..9.4no
300new32kyes18.8..20.5yes
300new64kyes8.5..8.7no
400new32kno27.1..27.6yes
400new64kno16.4..16.5yes
400new128kno9.7..9.8no
400new128kyes30.2..30.6yes
400new256kyes15.6..15.7yes
400new512kyes10.2..10.3no

Pentium 100 MHz / Symbios 53C810A
resolution queue buffer size "dd /dev/sda .."
running
scan time (sec) scan head stops
200off32koff6.8..8.4no
200off32kon6.4..9.0no
300off32koff7.9..8.7no
300off32kon20.2..21.5yes
300off64kon8.5..8.7no
400off32koff28.6..29.9yes
400off64koff16.5..17.8yes
400off128koff9.7..9.8no
400off128kon14.3..15.4yes
400off256kon15.7..18.4yes
400off512kon21.2..23.8yes
300old32kon20.1..21.5yes
300old64kon8.6..9.9no
400old32koff23.2..24.9yes
400old64koff9.7..9.8no
400old64kon37.0..37.3yes
400old128kon14.4..14.6yes
400old256kon10.2..10.3no
300new32koff7.9..8.2no
300new32kon20.0..20.4yes
300new64kon8.5..9.1no
400new32koff17.8..18.1yes
400new64koff9.7..9.8no
400new64kon36.9..37.3yes
400new128kon14.3..14.4yes
400new256kon10.2..10.3no
400new512kon10.3..10.4no

Thus, both an efficient command queueing and larger buffers can be essential in order to avoid carriage stops for resolutions of 300 and 400 dpi. This is especially evident for the Pentium/Adaptec combination: At 400 dpi, scans head stop can be avoided only, if command queueing on SG driver level is possible., and if a buffer size of 256kB is used.

An interesting "side result" is the fact, that the quite old and cheap 100 MHz Pentium box with a Symbios 53C810 SCSI adapter can be more efficient than the Celeron 433 with teh Adaptec 2940. I do not know, if the Symbios adapter is so more efficient than the Adaptec adapter, of if the respective Linux drivers are that different.

As a general conclusion, it seems to be a good idea to use a buffer size of 128kB or 256kB for scans with 300 dpi and above, unless a system has real memory shortages.

Finally, it must be pointed out that the results shown above do not give a guarantee, that large buffers and efficient command queueing avoid any scan head stop. "Real life" situations are generally more complicated. The Gimp for example can consume a considerable amount of memory, so that the kernel might need to swap some memory in order to allocate the buffers for scanimage and the SG driver.

Acknowlegdements

Douglas Gilbert, the maintainer of the Linux SG driver, answered many questions about several details of the SG driver, when I worked on the queueing implementation in the Sane SCSI library. Andreas Beck gave very useful suggestions, especially regarding the backward compatibility of the implementation of varaiable buffer size in the Sane SCSI library.

Abel Deuring


[1] More precisely, the time for the command scanimage -d sharp -l 0 -t 0 -x 216 -y 297 --mode Gray --Xresolution 400 --Yresolution 400 > /dev/null is approximately 10 seconds. This figure does not include the time needed to move the scan head back to the idle position, which is around 8 seconds. [back]