sane-project-website/old-archive/2001-01/0109.html

425 wiersze
19 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>sane-devel: snapscan</TITLE>
<META NAME="Author" CONTENT="Christian Nassau (nassau@math.uni-frankfurt.de)">
<META NAME="Subject" CONTENT="snapscan">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>snapscan</H1>
<!-- received="Wed Jan 10 01:57:02 2001" -->
<!-- isoreceived="20010110095702" -->
<!-- sent="Wed, 10 Jan 2001 11:21:03 +0100" -->
<!-- isosent="20010110102103" -->
<!-- name="Christian Nassau" -->
<!-- email="nassau@math.uni-frankfurt.de" -->
<!-- subject="snapscan" -->
<!-- id="200101101021.LAA02078@siegel.math.uni-frankfurt.de" -->
<STRONG>From:</STRONG> Christian Nassau (<A HREF="mailto:nassau@math.uni-frankfurt.de?Subject=Re:%20snapscan&In-Reply-To=&lt;200101101021.LAA02078@siegel.math.uni-frankfurt.de&gt;"><EM>nassau@math.uni-frankfurt.de</EM></A>)<BR>
<STRONG>Date:</STRONG> Wed Jan 10 2001 - 02:21:03 PST
<P>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0110.html">Christian Nassau: "Re: What is interfering during xscanimage/xsane?"</A>
<UL>
<LI><STRONG>Previous message:</STRONG> <A HREF="0108.html">Christian Nassau: "sanei_scsi_cmd / snapscan / Prisa640S"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0116.html">Henning Meier-Geinitz: "Re: snapscan"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0116.html">Henning Meier-Geinitz: "Re: snapscan"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#109">[ date ]</A>
<A HREF="index.html#109">[ thread ]</A>
<A HREF="subject.html#109">[ subject ]</A>
<A HREF="author.html#109">[ author ]</A>
</UL>
<HR NOSHADE><P>
<!-- body="start" -->
<P>
Subject: snapscan / SCSISource_Get(..) / Prisa640S
<BR>
<P>Dear snapscan folks,
<BR>
<P>Opening Apology:
<BR>
* I've been working on the snapscan backend for the last two
<BR>
* weeks or so, and wrote this e-mail simultaneously.
<BR>
* In the middle of it, it turned out that I had some
<BR>
* serious misunderstandings in my mind, which sheds a new light
<BR>
* on the beginning. I didn't revise the beginning since
<BR>
* it contains some hopefully interesting observations
<BR>
* nonetheless.
<BR>
<P>Sorry, but I think we've got to begin with some
<BR>
generalities.
<BR>
<P>As a backend, we're sandwiched between two channels of limited
<BR>
capacity: the scanner (with a limited transfer speed) and the
<BR>
frontend (with a limited capability to accept data). What
<BR>
should we do then? I think we
<BR>
<P>&nbsp;&nbsp;- should respect the scanner's limitations (so that our reader
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;process doesn't waste processor time), but we
<BR>
<P>&nbsp;&nbsp;- must ignore the frontend's limitations (as long as possible)
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;(sounds cruel, but the alternative is to run the scanner
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in &quot;stop-and-go&quot; mode at a lower speed, which (at best) makes
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a strange, unpleasant sound, and in practice means that
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the scanner has to stop from time to time)
<BR>
<P>(here the term &quot;frontend&quot; includes any post-processing the backend
<BR>
wants to make, like inversion, chroma correction, etc..)
<BR>
<P>Currently, the reader is (at least partially) frontend-driven:
<BR>
<P>&nbsp;&nbsp;- in &quot;blocking mode&quot; it only tries to get as many bytes as the
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;frontend requested. So it actually tries to simulate nonblocking
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mode.
<BR>
<P>&nbsp;&nbsp;- in nonblocking mode the child passes it's data through a pipe
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;to the parent, where it can be requested by the frontend.
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I assume that writing to a pipe can be quite slow if too much
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data is already waiting to be read. This is also confirmed by
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the results of my debugging sessions.
<BR>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(I timed these write instructions and found that towards the end
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;some instructions take 4 or 5 times longer than usual.
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Also, setting READER_WRITE_SIZE to 26128980 (= size of entire
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scan area) allowed the scanner to run without stopping, the
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reason presumably being that SCSISource_get(..) then runs
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;uninterrupted. (it is called only once)
<BR>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;An interesting test:
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;scanimage &lt;device&gt; &gt; /dev/null&quot;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;made my scanner stop from time to time, but
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;scanimage &lt;device&gt; -x 10 &gt; /dev/null&quot;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ran uninterrupted. I assume that the scanner's intended speed
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;(4.2 ms/line) should not depend on the width of the scan region,
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;so this problem should be related to the amount of data that
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is generated. I found it helpful to determine exactly
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the width at which the behaviour changes, and to inspect
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the resulting debugging messages. I once found that
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- x=55 made scanner stop 3 times (towards the end)
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- x=54 made scanimage lock (had to abort it)
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- x=53 ran uninterrupted, but with an ugly sound indicating
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;that it was constantly about to stop
<BR>
<P>(** I've just added a discussion of blocking/non-blocking mode
<BR>
at the end of this mail **)
<BR>
<P>By the way: the estimates done in SCSISource_get(..) have a
<BR>
systematic leak: if the expected number of bytes is larger
<BR>
than ps-&gt;absolute_max (which is approx. = SCANNER_BUF_SZ) the
<BR>
bytes that are available but don't fit into the buffer
<BR>
are forgotten when the routine is called the next time.
<BR>
The same applies to the bytes that are available, but don't
<BR>
form a full scan line. I have a modified version which
<BR>
corrects this. (I'm always referring to this version,
<BR>
which still makes the scanner stop from time to time, but
<BR>
does no longer let the expectation go down to 0 bytes.)
<BR>
<P>Isn't a SCANNER_BUF_SZ of 31744 *much* too small, and/or tuned
<BR>
to the scsi restrictions of old kernel versions? One should
<BR>
be more flexible and let the frontend suggest an appropriate
<BR>
value, and choose SCSIBUFFERMAX by default. I also suspect a
<BR>
memory leak somewhere: after changing SCANNER_BUF_SZ to a larger
<BR>
value I got segfaults, which disappeared after I declared
<BR>
snapscan_scanner.buf to be u_char[SCANNER_BUF_SZ+4096]. This
<BR>
really should be investigated.
<BR>
<P>And I wonder what measure_transferrate is doing: for some reason
<BR>
it seems to be simulating the postprocessing overhead, presumably
<BR>
to be included in the transferrate estimate. As I've said
<BR>
above, I think that is &quot;dead wrong&quot;, an absolute no-no !
<BR>
<P>But, maybe I don't understand what the READ_TRANSTIME instruction
<BR>
is supposed to do: are *we* reading the scanners transfer speed
<BR>
from the inquiry result, or is *the scanner* estimating our
<BR>
capability to accept data, by timing the two scsi read instructions
<BR>
that we're sending? That would also explain why we have to send
<BR>
a request for 0 bytes to the scanner. It would be helpful to put
<BR>
some explanations into snapscan's source code.
<BR>
<P>**** YES! Tests show that the scanner seems to be timing our
<BR>
capability to accept data, and to adjust the ms/line value
<BR>
accordingly! This puts everything in a different perspective:
<BR>
<P>&nbsp;- I can get uninterrupted scans by simulating a heavy system
<BR>
&nbsp;&nbsp;&nbsp;load with usleep(1000) in the measure_transferrate routine
<BR>
<P>&nbsp;- I cannot do it by opening a pipe and simulating a write/read
<BR>
&nbsp;&nbsp;&nbsp;cycle. The following extract of a debugging session (of a
<BR>
&nbsp;&nbsp;&nbsp;real scan) indicates that writing a small amount to a newly
<BR>
&nbsp;&nbsp;&nbsp;opened file is probably not representative for the average
<BR>
&n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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write_msecs=0.69
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...
<BR>
<P>&nbsp;- It seems what we should do is this:
<BR>
&nbsp;&nbsp;&nbsp;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If we want fast scans, the reader child should be asked
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to get all of the data as fast as it can and either
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- write the data to a pipe, or
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- write the data to a shared memory region
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in both cases we increase the memory requirements of our backend.
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If we use memory for data transfer one buffer certainly won't
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffice, since reading from it would block data acquisition.
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What about a circle of three shared memory regions?
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ummh, postprocessing (like chroma correction) may need to
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;access two buffers for reading, which then leaves
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;only one for writing, which could be a bit delicate...
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maybe we should allow N buffers, and determine N later...
<BR>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Let me stress this again: the child's execution *must not*
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;depend on the sane_read requests coming from the frontend
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(or, essentially equivalently, on the calls to SCSI_source_get).
<BR>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The child should get all the data at a speed that is negotiated
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in the measure_transferrate routine! If we use memory (rather
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;than pipes), one buffer does *not* suffice!
<BR>
<P>Using shared memory would be the best solution, since the data
<BR>
could be postprocessed in place, without having to copy it
<BR>
through a source chain. One could use the mm-library for the
<BR>
implementation of shared memory resources, but I don't know
<BR>
how good and/or portable that is.
<BR>
<P>I have actually begun to work on a modified snapscan-clone
<BR>
that uses shared memory. Unfortunately, this invalidates the
<BR>
entire SourceChain architecture of the current version,
<BR>
and inversion and chroma-correction have to be reimplemented.
<BR>
I'll make this code available when (and if) it works.
<BR>
<P>Christian
<BR>
<P>PS:
<BR>
*** Remarks on blocking/non-blocking mode
<BR>
<P>There seems to be some confusion or unclarity what one
<BR>
should mean by these terms. Note that the SANE specs
<BR>
don't say anything about it!
<BR>
<P>I would like to actually distinguish *three* different modes:
<BR>
<P>-- blocking mode (aka *strongly* blocking mode):
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;all of the data is fetched from the scanner (in the
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;first call to sane_read), then handed over to the frontend
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in digestable pieces
<BR>
<P>-- simulated non-blocking mode:
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;program runs in strongly blocking mode but asks
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;only for a convenient amount of data,
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data is then handed out to the frontend
<BR>
<P>-- non-blocking mode
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;program runs in strongly blocking mode (for
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the full image), but as a background process
<BR>
<P><P><P><P>&nbsp;&nbsp;&nbsp;
<BR>
<P><P><P><P><PRE>
--
Source code, list archive, and docs: <A HREF="http://www.mostang.com/sane/">http://www.mostang.com/sane/</A>
To unsubscribe: echo unsubscribe sane-devel | mail <A HREF="mailto:majordomo@mostang.com?Subject=Re:%20snapscan&In-Reply-To=&lt;200101101021.LAA02078@siegel.math.uni-frankfurt.de&gt;">majordomo@mostang.com</A>
</PRE>
<P><!-- body="end" -->
<HR NOSHADE>
<UL>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0110.html">Christian Nassau: "Re: What is interfering during xscanimage/xsane?"</A>
<LI><STRONG>Previous message:</STRONG> <A HREF="0108.html">Christian Nassau: "sanei_scsi_cmd / snapscan / Prisa640S"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0116.html">Henning Meier-Geinitz: "Re: snapscan"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0116.html">Henning Meier-Geinitz: "Re: snapscan"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#109">[ date ]</A>
<A HREF="index.html#109">[ thread ]</A>
<A HREF="subject.html#109">[ subject ]</A>
<A HREF="author.html#109">[ author ]</A>
</UL>
<!-- trailer="footer" -->
<HR NOSHADE>
<P>
<SMALL>
<EM>
This archive was generated by <A HREF="http://www.hypermail.org/">hypermail 2b29</A>
: <EM>Wed Jan 10 2001 - 01:57:25 PST</EM>
</EM>
</SMALL>
</BODY>
</HTML>