On Mon, 19 Mar 2001, Perrin Harkins wrote:

> While working on adding info on Berkeley DB to the Guide, I came across
> this statement:
>
> "If you need to access a dbm file in your mod_perl code in the read only
> mode the operation would be much faster if you keep the dbm file open
> (tied) all the time and therefore ready to be used. This will work with
> dynamic (read/write) databases accesses as well, but you need to use
> locking and data flushing to avoid data corruption."
>
> Is anyone aware of a safe to way to do multi-process read/write access
> through a dbm module other than BerkeleyDB.pm without tie-ing and
> untie-ing every time?  I thought that was the only safe thing to do
> because of buffering issues, but this seems to be implying that careful
> use of sync calls or something similar would do the trick.  Maybe this is
> just left over from before the problem with the old technique described in
> the DB_File docs was discovered?  Any comments?

Well, I wrote this based on my experience. I've used the code that does
locking coupled with sync() and it worked fine. I know that the guide
doesn't cover the details, this is one of the things that needs to be
done.

I also suppose that this issue should be properly benchmarked, but I think
that it's safe to assume that skipping tie/untie improves the speed.

Certainly the note "would be much faster,..." is correct if the
interaction with a dbm file is very light, which makes the overhead of tie
of a significance.

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


Reply via email to