Re: SANE Net backend suggestion...

Brian Macy (bmacy@sunshinecomputing.com)
Thu, 02 Dec 1999 09:10:33 -0800

David Mosberger-Tang wrote:
>
> On the down-side, if the scan server doesn't have sufficient disk
> space, it could prevent you from scanning altogether. Also, if you do
> have a fast link, writing it to the disk could slow things down. I
> still think it might be a good idea to do some buffering, but it's
> something that needs careful consideration.

Correct... though I have a 100Mbps switched full-duplex network with a
Dual Celeron Linux box with 2 SCSI controllers and my Win2k RC2 Celeron
500 box is having problems keeping up with the scanner greater than
150dpi... go figure, must be a Win2k/hardware issue as my K6-2 350
laptop keeps up.

Anyways, looked at it last night and it's actually saned.c::do_scan that
would be modified. First thing I plan on doing is changing the logic a
little. Right now it reads data from the scanner only if the output
buffer is completely empty... if the socket isn't ready to send more
data then it just does nothing, even if the buffer isn't full. Though
this makes no difference over the long run performance-wise since you
are always limited by the socket speed... it does mean there are large
delays between sane_read calls... so the time your scanner takes to fill
it's buffer must be greater than the time to transmit the data plus the
a percentage of the time to empty the buffer.

My though is to...
- First change the code in do_scan to make it read from the scanner if
there is room and the buffer and the socket isn't ready for writing.
This likely will make *zero* difference in the real world but it will at
least make it so the logic makes more sense to me. I'll submit a patch
once I'm reasonably happy with it.
- Second change I see is to add an option to saned to enable file
buffered scanning... that way if you never have a problem with your
remote machines keeping up with the scanning you can use the old method
which will most certainly use fewer resources. I'll submit a patch for
that too. I personally don't have a problem with requiring as much temp
space as the size of the image *if* people want to the intermediate
buffering.

Thoughts?

I take it pthreads is not common across all the platforms SANE supports.
I seem to remember vfork being used/wrapped and it does something funky
under OS/2. Anyways, this is doable without threading... though nicer
with it since both scanner and socket IO could be done in parallel.

Brian Macy

--
Source code, list archive, and docs: http://www.mostang.com/sane/
To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com