On Jun 14, 2007, at 4:50 AM, Hans Dieter Pearcey wrote:
> I had been thinking of putting it into an Apache::Session.
Serializing a Searcher so that the state of the *Searcher* *object*
can be preserved between requests? That wouldn't aid performance,
even if Searcher could be serialized.
What you're describing is analogous to serializing a filehandle --
you can write code to do it, but you probably don't want to. You can
record the filehandle's file position. In theory you can even
serialize the bytes held in the filehandle's read buffer, though
that's a bizarre thing to do, since the buffer is just an in-memory
cache that spares you from having to access the disk with every read op.
But what will you get when you deserialize that filehandle? Does the
file even exist anymore? Is the data from the old read buffer still
valid? Is the file the same length? Why would you ever do something
like serialize and restore a filehandle, rather than just open the
file again?
I think you may have been misled by the phrase, "caching a Searcher",
which appears in the KS documentation. The point is to cache a
Searcher *in* *RAM*, so that you don't pay the startup costs of
reading a bunch of data off disk and into RAM over and over with each
new search.
> Will your suggestion survive a fork usefully?
You won't get memory errors, but you can't use the Searcher in both
processes. Searchers keep several filehandles open. If both parent
and child attempt to read from the shared file descriptors after the
fork, they'll interfere with each other.
Because Searchers have a large RAM footprint due to all the caching,
yet you can't use duped Searchers because of IO sync issues, you
probably want to avoid creating them in parent processes.
> My app primarily differs in that I was planning on having many
> invindexes, two
> or three per user, so opening them all at program start would
> probably be
> inefficient (there are several hundred of them).
OK. With that architecture, you'll need to factor in the time it
takes to begin reading from any one of those invindexes.
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/