Perrin Harkins wrote:
> 
> On Fri, 17 Nov 2000, Joshua Chamas wrote:
> > I'm working on a new module to be used for mod_perl style
> > caching.  I'm calling it MLDBM::Sync because its a subclass
> > of MLDBM that makes sure concurrent access is serialized with
> > flock() and i/o flushing between reads and writes.
> 
> I looked through the code and couldn't see how you are doing i/o
> flushing.  This is more of an issue with Berkeley DB than SDBM I think,
> since Berkeley DB will cache things in memory.  Can you point to me it?
> 
> Also, I'm confused on the usage.  Do you open the dbm file and keep it
> open, or do you tie/untie on every request?
> 

Yes, tie/untie every request as this consistently flushes i/o
in an atomic way for SDBM_File, DB_File, GDBM_File...
Without this data can be lost, even for SDBM_File, if multiple
processes have tied to these DBMs and are writing concurrently.  
SDBM_File doesn't get corrupt though like DB_File, so access to 
it would seem error free without this sync method.

On my box, some rough numbers in writes per sec, with doing a
tie/untie for each write, are:

  sync writes/sec with tie/untie

SDBM_File       1000
DB_File         30
GDBM_File       40

Note that on a RAM disk in Linux, DB_File goes to 500 writes per sec,
but setting up a RAM disk is a pain, so I'd probably use File::Cache
which gets about 300 writes per sec on the file system.

> You might want to look at the Mason caching API.  It would be nice to make
> an interface like that available on top of a module like this.
> 

Because of the 1024 byte SDBM_File limit, Mason would probably be
better off using File::Cache for caching, but for little bits
of data SDBM_File with MLDBM::Sync works really well.

Thanks for the feedback.  BTW, if you want to experiment with it,
the module code I posted will only provide SDBM_File access.  
I have a fixed version which will work for any DBM format that
MLDBM works with, so let me know and I'll send you my latest.

--Joshua

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to